初始化
This commit is contained in:
12
BLW_Log/Controllers/ApiLogController.cs
Normal file
12
BLW_Log/Controllers/ApiLogController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class ApiLogController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
267
BLW_Log/Controllers/BlockIPController.cs
Normal file
267
BLW_Log/Controllers/BlockIPController.cs
Normal file
@@ -0,0 +1,267 @@
|
||||
using System.Security.Policy;
|
||||
using Common;
|
||||
using DAL.PGModels;
|
||||
using LinqToDB.Common.Internal.Cache;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.VisualBasic;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class BlockIPController : ControllerBase
|
||||
{
|
||||
|
||||
public readonly IMemoryCache _memoryCache;
|
||||
private readonly PostgresContext dbContext;
|
||||
public BlockIPController(PostgresContext db, IMemoryCache memoryCache)
|
||||
{
|
||||
this.dbContext = db;
|
||||
this._memoryCache = memoryCache;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取黑名单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GetBlockLWSetData()
|
||||
{
|
||||
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
info.isok = true;
|
||||
try
|
||||
{
|
||||
ReturnInfo data = await Http.HttpPostSendData(new { }, "api/GetBlockLWSetData");
|
||||
info.response = data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置黑名单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> BlockLWSet([FromBody] Block_NameList L)
|
||||
{
|
||||
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
info.isok = true;
|
||||
try
|
||||
{
|
||||
ReturnInfo data = await Http.HttpPostSendData(L, "api/BlockLWSet");
|
||||
info.response = data;
|
||||
|
||||
BlockIplog blockIplog = new BlockIplog();
|
||||
if (string.IsNullOrEmpty(L.Human))
|
||||
{
|
||||
L.Human = "admin";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
blockIplog.Human = L.Human;
|
||||
blockIplog.BlockContent = JsonConvert.SerializeObject(L);
|
||||
blockIplog.CreateTime = DateTime.Now;
|
||||
dbContext.BlockIplogs.Add(blockIplog);
|
||||
await dbContext.SaveChangesAsync();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除黑名单
|
||||
///
|
||||
/// 字典里面需要有个hotelcode
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> BlockLWRemove([FromBody] Dictionary<string, string> L)
|
||||
{
|
||||
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
info.isok = true;
|
||||
try
|
||||
{
|
||||
ReturnInfo data = await Http.HttpPostFormSendData(L, "api/BlockLWRemove");
|
||||
info.response = data;
|
||||
info.response = "";
|
||||
|
||||
bool bf = L.TryGetValue("Human", out string Human);
|
||||
|
||||
BlockIplog blockIplog = new BlockIplog();
|
||||
if (!bf)
|
||||
{
|
||||
blockIplog.Human = "admin";
|
||||
}
|
||||
blockIplog.Human = Human;
|
||||
blockIplog.BlockContent = JsonConvert.SerializeObject(L);
|
||||
blockIplog.CreateTime = DateTime.Now;
|
||||
dbContext.BlockIplogs.Add(blockIplog);
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// UDP 超时不再处理数据的时间
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GetDefineUDPLostDataInterval()
|
||||
{
|
||||
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
info.isok = true;
|
||||
try
|
||||
{
|
||||
ReturnInfo data = await Http.HttpPostSendData(new { }, "api/GetDefineUDPLostDataInterval");
|
||||
info.response = data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取UDP多少包丢一包的数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GetDefineUDPLostDataRate()
|
||||
{
|
||||
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
info.isok = true;
|
||||
try
|
||||
{
|
||||
ReturnInfo data = await Http.HttpPostSendData(new { }, "api/GetDefineUDPLostDataRate");
|
||||
info.response = data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 统计的时间间隔
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GetTongJiTimerInterval()
|
||||
{
|
||||
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
info.isok = true;
|
||||
try
|
||||
{
|
||||
ReturnInfo data = await Http.HttpPostSendData(new { }, "api/GetTongJiTimerInterval");
|
||||
info.response = data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 三合一
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<ReturnInfo> GetConfigParameterList()
|
||||
{
|
||||
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
info.isok = true;
|
||||
try
|
||||
{
|
||||
|
||||
Task<ReturnInfo> data1 = Http.HttpPostSendData(new { }, "api/GetDefineUDPLostDataInterval");
|
||||
Task<ReturnInfo> data2 = Http.HttpPostSendData(new { }, "api/GetDefineUDPLostDataRate");
|
||||
Task<ReturnInfo> data3 = Http.HttpPostSendData(new { }, "api/GetTongJiTimerInterval");
|
||||
await Task.WhenAll(data1,data2,data3);
|
||||
|
||||
var U= new {超时08=data1.Result.response, 丢弃比例=data2.Result.response,统计周期=data3.Result.response};
|
||||
info.response = U;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public async Task<string> GetRoomCount()
|
||||
{
|
||||
|
||||
//ReturnInfo r = new ReturnInfo();
|
||||
//r.isok = true;
|
||||
try
|
||||
{
|
||||
string Key = "GetRoomCount";
|
||||
object ooo = _memoryCache.Get(Key);
|
||||
if (ooo != null)
|
||||
{
|
||||
//r.isok = true;
|
||||
//r.response = ooo.ToString();
|
||||
return ooo.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var options = new RestClientOptions("http://www.boonlive-rcu.com:7000/");
|
||||
var client = new RestClient(options);
|
||||
|
||||
var request = new RestRequest("api/values/GetRoomCount");
|
||||
RestResponse response = await client.GetAsync(request);
|
||||
string? str1 = response.Content;
|
||||
_memoryCache.Set(Key, str1, DateTimeOffset.Now.AddHours(2));
|
||||
return str1;
|
||||
//r.isok = true;
|
||||
//r.response = str1;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
//r.isok = false;
|
||||
//r.message = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
554
BLW_Log/Controllers/DbInfoController.cs
Normal file
554
BLW_Log/Controllers/DbInfoController.cs
Normal file
@@ -0,0 +1,554 @@
|
||||
using BLW_Log.Models;
|
||||
using Common;
|
||||
using DAL.PGModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NLog;
|
||||
using Npgsql; // 添加 Npgsql 引用
|
||||
using System.Data.Common;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class DbInfoController : ControllerBase
|
||||
{
|
||||
private readonly PostgresContext dbContext;
|
||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DbInfoController(PostgresContext db)
|
||||
{
|
||||
this.dbContext = db;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取历史日志
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<ReturnInfo> GetHisLog([FromBody] HisLogQuery QueryData)
|
||||
{
|
||||
ReturnInfo info = new ReturnInfo { isok = true };
|
||||
|
||||
try
|
||||
{
|
||||
// 验证输入参数
|
||||
if (QueryData == null)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "查询参数不能为空";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 解析时间参数
|
||||
if (!DateTime.TryParse(QueryData.Start_Time, out DateTime sst))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "开始时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
if (!DateTime.TryParse(QueryData.End_Time, out DateTime eet))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 验证时间范围
|
||||
if (eet < sst)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间不能小于开始时间";
|
||||
return info;
|
||||
}
|
||||
|
||||
long l1 = Tools.ToUnixTimestampByMilliseconds(sst);
|
||||
long l2 = Tools.ToUnixTimestampByMilliseconds(eet);
|
||||
// 构建 SQL 查询(添加实际时间过滤条件)
|
||||
string sql = $"""
|
||||
SELECT "Room","count"("Room")
|
||||
FROM "public"."{QueryData.HotelCode}_Rooms"
|
||||
WHERE "LoopAddr" <> '000000000' AND "RcuStatus" = TRUE AND "ModuleStopTime" BETWEEN {l1} AND {l2}
|
||||
GROUP BY "Room";
|
||||
""";
|
||||
string sql0 = $"""
|
||||
SELECT "Room","count"("Room")
|
||||
FROM "public"."{QueryData.HotelCode}_Rooms"
|
||||
WHERE "LoopAddr" = '000000000' AND "RcuStatus" = FALSE AND "ModuleStopTime" BETWEEN {l1} AND {l2}
|
||||
GROUP BY "Room";
|
||||
""";
|
||||
string sql1 = $"""
|
||||
SELECT "Room","count"("Room")
|
||||
FROM "public"."{QueryData.HotelCode}_Rooms"
|
||||
WHERE "ModuleStopTime" BETWEEN {l1} AND {l2}
|
||||
GROUP BY "Room";
|
||||
""";
|
||||
string sql2 = $"""
|
||||
SELECT "Room", "count" ("Room")
|
||||
FROM "public"."{QueryData.HotelCode}_Rooms"
|
||||
WHERE "ModuleStopTime" BETWEEN {l1} AND {l2} AND "StateTyp" IN('6','7','8') AND "RcuStatus" = TRUE
|
||||
GROUP BY "Room";
|
||||
""";
|
||||
string sql3 = $"""
|
||||
SELECT "Room", "count" ("Room")
|
||||
FROM "public"."{QueryData.HotelCode}_Rooms"
|
||||
WHERE "ModuleStopTime" BETWEEN {l1} AND {l2} AND "StateTyp" IN('2','3','4','5') AND "RcuStatus" = TRUE
|
||||
GROUP BY "Room";
|
||||
""";
|
||||
|
||||
// 使用 ADO.NET 方式执行查询
|
||||
|
||||
var results = ExecuteSqlQuery(sql);
|
||||
var results0 = ExecuteSqlQuery(sql0);
|
||||
var results1 = ExecuteSqlQuery(sql1);
|
||||
var results2 = ExecuteSqlQuery(sql2);
|
||||
var results3 = ExecuteSqlQuery(sql3);
|
||||
|
||||
|
||||
|
||||
List<CountTongJi> lll = [];
|
||||
|
||||
foreach (Dictionary<string, object> item in results)
|
||||
{
|
||||
string? RoomNUM = item["Room"]?.ToString();
|
||||
string? Count = item["count"]?.ToString();
|
||||
|
||||
var q0 = results0.FirstOrDefault(A => A["Room"].ToString().Equals(RoomNUM));
|
||||
var q1 = results1.FirstOrDefault(A => A["Room"].ToString().Equals(RoomNUM));
|
||||
var q2 = results2.FirstOrDefault(A => A["Room"].ToString().Equals(RoomNUM));
|
||||
var q3 = results3.FirstOrDefault(A => A["Room"].ToString().Equals(RoomNUM));
|
||||
|
||||
string? Count0 = q0?["count"]?.ToString() ?? "0";
|
||||
string? Count1 = q1?["count"]?.ToString() ?? "0";
|
||||
string? Count2 = q2?["count"]?.ToString() ?? "0";
|
||||
string? Count3 = q3?["count"]?.ToString() ?? "0";
|
||||
|
||||
CountTongJi c = new()
|
||||
{
|
||||
RoomNum = RoomNUM,
|
||||
CountErr = Count,
|
||||
CountOff = Count0,
|
||||
CountAll = Count1,
|
||||
CountDoor = Count2,
|
||||
CountLeida = Count3
|
||||
};
|
||||
lll.Add(c);
|
||||
}
|
||||
info.isok = true;
|
||||
info.response = lll;
|
||||
info.message = "查询成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "获取历史日志失败");
|
||||
info.isok = false;
|
||||
info.message = $"查询失败: {ex.Message}";
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
public class CountTongJi
|
||||
{
|
||||
public string? RoomNum { get; set; }
|
||||
public string? CountErr { get; set; }
|
||||
public string? CountOff { get; set; }
|
||||
public string? CountAll { get; set; }
|
||||
public string? CountDoor { get; set; }
|
||||
public string? CountLeida { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取离线日志
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public ReturnInfo GetOfflineLog([FromBody] HisLogQuery QueryData)
|
||||
{
|
||||
ReturnInfo info = new ReturnInfo { isok = true };
|
||||
|
||||
try
|
||||
{
|
||||
// 验证输入参数
|
||||
if (QueryData == null)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "查询参数不能为空";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 解析时间参数
|
||||
if (!DateTime.TryParse(QueryData.Start_Time, out DateTime sst))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "开始时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
if (!DateTime.TryParse(QueryData.End_Time, out DateTime eet))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 验证时间范围
|
||||
if (eet < sst)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间不能小于开始时间";
|
||||
return info;
|
||||
}
|
||||
|
||||
long l1 = Tools.ToUnixTimestampByMilliseconds(sst);
|
||||
long l2 = Tools.ToUnixTimestampByMilliseconds(eet);
|
||||
// 构建 SQL 查询(添加实际时间过滤条件)
|
||||
string sql = $"""
|
||||
SELECT "Room","count"("Room")
|
||||
FROM "public"."{QueryData.HotelCode}_Rooms"
|
||||
WHERE "LoopAddr" = '000000000' AND "RcuStatus" = FALSE AND "ModuleStopTime" BETWEEN {l1} AND {l2}
|
||||
GROUP BY "Room";
|
||||
""";
|
||||
// 注意:实际表结构可能不同,请修改create_time为实际时间字段
|
||||
|
||||
// 使用 ADO.NET 方式执行查询
|
||||
var results = ExecuteSqlQuery(sql);
|
||||
|
||||
info.isok = true;
|
||||
info.response = results;
|
||||
info.message = "查询成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "获取历史日志失败");
|
||||
info.isok = false;
|
||||
info.message = $"查询失败: {ex.Message}";
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取房间日志
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public ReturnInfo GetRoomLog([FromBody] RoomLogQuery QueryData)
|
||||
{
|
||||
ReturnInfo info = new ReturnInfo { isok = true };
|
||||
|
||||
try
|
||||
{
|
||||
// 验证输入参数
|
||||
if (QueryData == null)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "查询参数不能为空";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 解析时间参数
|
||||
if (!DateTime.TryParse(QueryData.Start_Time, out DateTime sst))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "开始时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
if (!DateTime.TryParse(QueryData.End_Time, out DateTime eet))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 验证时间范围
|
||||
if (eet < sst)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间不能小于开始时间";
|
||||
return info;
|
||||
}
|
||||
|
||||
long l1 = Tools.ToUnixTimestampByMilliseconds(sst);
|
||||
long l2 = Tools.ToUnixTimestampByMilliseconds(eet);
|
||||
// 构建 SQL 查询(添加实际时间过滤条件)
|
||||
string sql = $"""
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
"public"."{QueryData.HotelCode}_Rooms"
|
||||
WHERE
|
||||
"LoopAddr" <> '000000000'
|
||||
AND "Room" = '{QueryData.RoomNum}'
|
||||
AND "ModuleStopTime" BETWEEN {l1} AND {l2}
|
||||
AND "RcuStatus" = TRUE;
|
||||
""";
|
||||
// 注意:实际表结构可能不同,请修改create_time为实际时间字段
|
||||
|
||||
// 使用 ADO.NET 方式执行查询
|
||||
var results = ExecuteSqlQuery(sql);
|
||||
|
||||
info.isok = true;
|
||||
info.response = results;
|
||||
info.message = "查询成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "获取历史日志失败");
|
||||
info.isok = false;
|
||||
info.message = $"查询失败: {ex.Message}";
|
||||
}
|
||||
return info;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取房间日志
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public ReturnInfo GetRoomOffOnLineLog([FromBody] RoomLogQuery QueryData)
|
||||
{
|
||||
ReturnInfo info = new ReturnInfo { isok = true };
|
||||
|
||||
try
|
||||
{
|
||||
// 验证输入参数
|
||||
if (QueryData == null)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "查询参数不能为空";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 解析时间参数
|
||||
if (!DateTime.TryParse(QueryData.Start_Time, out DateTime sst))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "开始时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
if (!DateTime.TryParse(QueryData.End_Time, out DateTime eet))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 验证时间范围
|
||||
if (eet < sst)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间不能小于开始时间";
|
||||
return info;
|
||||
}
|
||||
|
||||
long l1 = Tools.ToUnixTimestampByMilliseconds(sst);
|
||||
long l2 = Tools.ToUnixTimestampByMilliseconds(eet);
|
||||
// 构建 SQL 查询(添加实际时间过滤条件)
|
||||
string sql = $"""
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
"public"."{QueryData.HotelCode}_SimplificationLogs"
|
||||
WHERE
|
||||
"Room" = '{QueryData.RoomNum}'
|
||||
AND "Address" = '000000000'
|
||||
AND "TimeStamp" BETWEEN {l1} AND {l2}
|
||||
ORDER BY
|
||||
"TimeStamp"
|
||||
""";
|
||||
// 注意:实际表结构可能不同,请修改create_time为实际时间字段
|
||||
|
||||
// 使用 ADO.NET 方式执行查询
|
||||
var results = ExecuteSqlQuery(sql);
|
||||
|
||||
info.isok = true;
|
||||
info.response = results;
|
||||
info.message = "查询成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "获取历史日志失败");
|
||||
info.isok = false;
|
||||
info.message = $"查询失败: {ex.Message}";
|
||||
}
|
||||
return info;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取回路日志
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public ReturnInfo GetAddressLog([FromBody] AddressLogQuery QueryData)
|
||||
{
|
||||
ReturnInfo info = new ReturnInfo { isok = true };
|
||||
|
||||
try
|
||||
{
|
||||
// 验证输入参数
|
||||
if (QueryData == null)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "查询参数不能为空";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 解析时间参数
|
||||
if (!DateTime.TryParse(QueryData.Start_Time, out DateTime sst))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "开始时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
if (!DateTime.TryParse(QueryData.End_Time, out DateTime eet))
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间格式无效";
|
||||
return info;
|
||||
}
|
||||
|
||||
// 验证时间范围
|
||||
if (eet < sst)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "结束时间不能小于开始时间";
|
||||
return info;
|
||||
}
|
||||
|
||||
long l1 = Tools.ToUnixTimestampByMilliseconds(sst);
|
||||
long l2 = Tools.ToUnixTimestampByMilliseconds(eet);
|
||||
// 构建 SQL 查询(添加实际时间过滤条件)
|
||||
string sql = $"""
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
"public"."{QueryData.HotelCode}_SimplificationLogs"
|
||||
WHERE
|
||||
"Room" = '{QueryData.RoomNum}'
|
||||
AND "Address" = '{QueryData.Address}'
|
||||
AND "TimeStamp" BETWEEN {l1} AND {l2}
|
||||
ORDER BY
|
||||
"TimeStamp" ;
|
||||
""";
|
||||
// 注意:实际表结构可能不同,请修改create_time为实际时间字段
|
||||
|
||||
// 使用 ADO.NET 方式执行查询
|
||||
var results = ExecuteSqlQuery(sql);
|
||||
|
||||
info.isok = true;
|
||||
info.response = results;
|
||||
info.message = "查询成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "获取历史日志失败");
|
||||
info.isok = false;
|
||||
info.message = $"查询失败: {ex.Message}";
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取问题清单
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public ReturnInfo GetIssueList()
|
||||
{
|
||||
ReturnInfo info = new ReturnInfo { isok = true };
|
||||
|
||||
try
|
||||
{
|
||||
// 构建 SQL 查询(添加实际时间过滤条件)
|
||||
string sql = $"""
|
||||
SELECT *
|
||||
FROM "public"."Log_Filter_Rule";
|
||||
""";
|
||||
// 使用 ADO.NET 方式执行查询
|
||||
var results = ExecuteSqlQuery(sql);
|
||||
|
||||
info.isok = true;
|
||||
info.response = results;
|
||||
info.message = "查询成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "获取历史日志失败");
|
||||
info.isok = false;
|
||||
info.message = $"查询失败: {ex.Message}";
|
||||
}
|
||||
return info;
|
||||
}
|
||||
/// <summary>
|
||||
/// 执行原始 SQL 查询并返回结果
|
||||
/// </summary>
|
||||
private List<Dictionary<string, object>> ExecuteSqlQuery(string sql)
|
||||
{
|
||||
var results = new List<Dictionary<string, object>>();
|
||||
|
||||
var connection = dbContext.Database.GetDbConnection();
|
||||
if (connection.State != System.Data.ConnectionState.Open)
|
||||
{
|
||||
connection.Open();
|
||||
}
|
||||
|
||||
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = sql;
|
||||
command.CommandTimeout = 30; // 30秒超时
|
||||
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
var row = new Dictionary<string, object>();
|
||||
|
||||
for (int i = 0; i < reader.FieldCount; i++)
|
||||
{
|
||||
string columnName = reader.GetName(i);
|
||||
object value = reader.IsDBNull(i) ? null : reader.GetValue(i);
|
||||
row.Add(columnName, value);
|
||||
}
|
||||
|
||||
results.Add(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询参数类
|
||||
/// </summary>
|
||||
public class HisLogQuery
|
||||
{
|
||||
[JsonPropertyName("hotelCode")]
|
||||
public string HotelCode { get; set; }
|
||||
|
||||
[JsonPropertyName("start_time")]
|
||||
public string Start_Time { get; set; }
|
||||
|
||||
[JsonPropertyName("end_time")]
|
||||
public string End_Time { get; set; }
|
||||
}
|
||||
|
||||
public class RoomLogQuery : HisLogQuery
|
||||
{
|
||||
[JsonPropertyName("roomnum")]
|
||||
public string RoomNum { get; set; }
|
||||
}
|
||||
|
||||
public class AddressLogQuery : RoomLogQuery
|
||||
{
|
||||
[JsonPropertyName("address")]
|
||||
public string Address { get; set; }
|
||||
}
|
||||
|
||||
public class Emp
|
||||
{
|
||||
public string? em { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
51
BLW_Log/Controllers/EndPointMonitorController.cs
Normal file
51
BLW_Log/Controllers/EndPointMonitorController.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Common;
|
||||
using Commonlib;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class EndPointMonitorController : Controller
|
||||
{
|
||||
public static string BaseUrl = "http://www.boonlive-rcu.com:7000/";
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public List<MonitorEndPoint> Query()
|
||||
{
|
||||
string Url = "api/Monitor/GetMonitorData";
|
||||
var options = new RestClientOptions(BaseUrl);
|
||||
var client = new RestClient(options);
|
||||
|
||||
var request = new RestRequest(Url);
|
||||
|
||||
string? hostlist = client.Post(request).Content;
|
||||
ReturnInfo info = JsonConvert.DeserializeObject<ReturnInfo>(hostlist ?? string.Empty);
|
||||
List<MonitorEndPoint> lll = JsonConvert.DeserializeObject<List<MonitorEndPoint>>(info.response?.ToString() ?? string.Empty);
|
||||
return lll;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost()]
|
||||
public string SetData([FromBody] MonitorData ddd)
|
||||
{
|
||||
try
|
||||
{
|
||||
string Url = "api/Monitor/SetMonitor";
|
||||
var options = new RestClientOptions(BaseUrl);
|
||||
var client = new RestClient(options);
|
||||
var request = new RestRequest(Url);
|
||||
|
||||
request.AddJsonBody(ddd);
|
||||
string? hostlist = client.Post(request).Content;
|
||||
return hostlist;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
134
BLW_Log/Controllers/FileUploadController.cs
Normal file
134
BLW_Log/Controllers/FileUploadController.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace SupplierManager.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class FileUploadController : ControllerBase
|
||||
{
|
||||
|
||||
public static string[] FolderG = new string[] {"face" };
|
||||
|
||||
[Authorize()]
|
||||
[HttpPost()]
|
||||
public async Task<IActionResult> UploadFile([FromForm] UploadFileModel model)
|
||||
{
|
||||
if (model.File == null || model.File.Length == 0)
|
||||
{
|
||||
return BadRequest("没有上传任何文件");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 获取文件名和扩展名
|
||||
string originalFileName = Path.GetFileNameWithoutExtension(model.File.FileName);
|
||||
string fileExtension = Path.GetExtension(model.File.FileName); // 包含扩展名前的点(如.jpg)
|
||||
|
||||
// 生成8位GUID(取完整GUID的前8位字符)
|
||||
string guidPart = Guid.NewGuid().ToString("N")[..16];
|
||||
|
||||
// 组合新文件名:原文件名_8位GUID.扩展名
|
||||
string newFileName = $"{originalFileName}_{guidPart}{fileExtension}";
|
||||
|
||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(),
|
||||
$"wwwroot/Uploads/{model.Folder}",
|
||||
newFileName);
|
||||
|
||||
using (var stream = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
await model.File.CopyToAsync(stream);
|
||||
}
|
||||
return Ok(new { FileName = newFileName });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BadRequest(new { Message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
public record DF
|
||||
{
|
||||
public string? FileName { get; set; }
|
||||
}
|
||||
// 示例:通过文件名获取图片
|
||||
[Authorize()]
|
||||
[HttpPost()]
|
||||
public IActionResult DownloadFile([FromBody]DF imageName)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 拼接图片物理路径(假设图片存放在项目的 wwwroot/images 目录下)
|
||||
var imagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/", imageName.FileName);
|
||||
|
||||
// 检查文件是否存在
|
||||
if (!System.IO.File.Exists(imagePath))
|
||||
{
|
||||
return NotFound("Image not found");
|
||||
}
|
||||
if (imageName.FileName.Contains(".."))
|
||||
{
|
||||
return BadRequest("Invalid file name");
|
||||
}
|
||||
|
||||
|
||||
// 读取文件流并返回
|
||||
var imageStream = System.IO.File.OpenRead(imagePath);
|
||||
|
||||
// 根据扩展名自动设置 Content-Type(MIME类型)
|
||||
var mimeType = GetMimeType(imageName.FileName);
|
||||
|
||||
return File(imageStream, mimeType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"Internal server error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize()]
|
||||
[HttpPost()]
|
||||
public IActionResult GetFileNameList()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 拼接图片物理路径(假设图片存放在项目的 wwwroot/images 目录下)
|
||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(),
|
||||
$"wwwroot/Download/customization","");
|
||||
|
||||
string[] files= System.IO.Directory.GetFiles(filePath);
|
||||
var myfiles= files.Select(A=>Path.GetFileName(A));
|
||||
return Ok(new { FileNameList = myfiles });
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"Internal server error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取 MIME 类型映射
|
||||
private string GetMimeType(string fileName)
|
||||
{
|
||||
var extension = Path.GetExtension(fileName).ToLowerInvariant();
|
||||
return
|
||||
extension switch
|
||||
{
|
||||
".jpg" => "image/jpeg",
|
||||
".jpeg" => "image/jpeg",
|
||||
".png" => "image/png",
|
||||
".gif" => "image/gif",
|
||||
".xls" =>"application/vnd.ms-excel",
|
||||
".xlsx"=>"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
_ => "application/octet-stream" // 默认类型
|
||||
};
|
||||
}
|
||||
}
|
||||
public class UploadFileModel
|
||||
{
|
||||
public IFormFile File { get; set; }
|
||||
public string Folder { get; set; }
|
||||
}
|
||||
}
|
||||
63
BLW_Log/Controllers/HomeController.cs
Normal file
63
BLW_Log/Controllers/HomeController.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using BLW_Log.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NLog;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
//private static Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet("stream")]
|
||||
public async Task StreamSSEvents()
|
||||
{
|
||||
HttpContext.Response.ContentType = "text/event-stream";
|
||||
HttpContext.Response.Headers.Add("Cache-Control", "no-cache");
|
||||
HttpContext.Response.Headers.Add("Connection", "keep-alive");
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var data = new
|
||||
{
|
||||
id = Guid.NewGuid().ToString(),
|
||||
eventmm = "111",
|
||||
data = "22222"
|
||||
};
|
||||
|
||||
var responseData = $"id: {data.id} ";
|
||||
responseData += $"event: {data.eventmm} ";
|
||||
responseData += $"data: 111111111111111 ";
|
||||
|
||||
await HttpContext.Response.WriteAsync(responseData, Encoding.UTF8);
|
||||
await Task.Delay(2000); // <20>ȴ<EFBFBD>2<EFBFBD><32><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>¼<EFBFBD>
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
12
BLW_Log/Controllers/IndexController.cs
Normal file
12
BLW_Log/Controllers/IndexController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class IndexController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
109
BLW_Log/Controllers/LeiDaController.cs
Normal file
109
BLW_Log/Controllers/LeiDaController.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using RestSharp;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class LeiDaController : ControllerBase
|
||||
{
|
||||
|
||||
public readonly IMemoryCache _memoryCache;
|
||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public readonly IConfiguration? _configurationManager;
|
||||
|
||||
public LeiDaController(IMemoryCache cache, IConfiguration config)
|
||||
{
|
||||
_memoryCache = cache;
|
||||
_configurationManager = config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录接口
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> Login(LoginData data)
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
dic.Add("username", data.username);
|
||||
dic.Add("password", data.password);
|
||||
r = await Http.HttpPostSendData(dic, "/api/LogSystemlogin");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.isok = false;
|
||||
r.response = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取RCU的状态
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GetRCUStatus(dynamic data)
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
dic.Add("code", data.code);
|
||||
dic.Add("creatDate", data.creatDate);
|
||||
dic.Add("roomNumber", data.roomNumber);
|
||||
r = await Http.HttpGetSendData(dic, "/api/GetRCUStatus");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.isok = false;
|
||||
r.response = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取房型及其 回路信息
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GetRoomTypeAndModalsList(HotelInfo data)
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
string KKK = "GetRoomTypeAndModalsList_"+data.code;
|
||||
object ooo = _memoryCache.Get(KKK);
|
||||
if (ooo != null)
|
||||
{
|
||||
r = (ReturnInfo)ooo;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = await Http.HttpGetSendData(data, "/api/GetRoomTypeAndModalsListLog");
|
||||
_memoryCache.Set(KKK,r,new TimeSpan(0,50,0));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.isok = false;
|
||||
r.response = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
12
BLW_Log/Controllers/LogController.cs
Normal file
12
BLW_Log/Controllers/LogController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class LogController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
144
BLW_Log/Controllers/LoginController.cs
Normal file
144
BLW_Log/Controllers/LoginController.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Logging;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
using NLog;
|
||||
using static IronPython.Modules._ast;
|
||||
using Common;
|
||||
using BLW_Log.Models;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class LoginController : ControllerBase
|
||||
{
|
||||
|
||||
|
||||
|
||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
public IConfiguration? configuration { get; set; }
|
||||
public LoginController(IConfiguration _configuration)
|
||||
{
|
||||
configuration = _configuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
/// <param name="username">用户名</param>
|
||||
/// <param name="password">密码</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ReturnInfo Login([FromBody] LoginData data)
|
||||
{
|
||||
|
||||
ReturnInfo res = new ReturnInfo();
|
||||
|
||||
try
|
||||
{
|
||||
string? password = data.password;
|
||||
string? username = data.username;
|
||||
|
||||
var result = StaticData.scope1.GetVariable("LoginData");
|
||||
|
||||
var str= System.Text.Json.JsonSerializer.Serialize(result);
|
||||
var dic= System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, string>>(str);
|
||||
|
||||
string TokenString = "";
|
||||
if (result != null)
|
||||
{
|
||||
if (dic.TryGetValue(username, out string pwd))
|
||||
{
|
||||
if (pwd.Equals(password))
|
||||
{
|
||||
TokenString = GetToken(data);
|
||||
res.isok = true;
|
||||
res.response = TokenString;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.isok = false;
|
||||
res.message = "密码错误";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.isok = false;
|
||||
res.message = "用户不存在";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
res.message = ex.Message;
|
||||
res.isok = false;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private string GetToken(LoginData? entity)
|
||||
{
|
||||
string TokenString;
|
||||
var claims = new Claim[]
|
||||
{
|
||||
//new Claim(ClaimTypes.NameIdentifier, entity.Id.ToString()),
|
||||
//new Claim(ClaimTypes.MobilePhone, entity.Mobile.ToString()),
|
||||
//new Claim(ClaimTypes.Name, entity.Username)
|
||||
};
|
||||
|
||||
var secretByte = Encoding.UTF8.GetBytes(configuration["JwT:SecretKey"]);
|
||||
var signingKey = new SymmetricSecurityKey(secretByte);
|
||||
var a = SecurityAlgorithms.HmacSha256;
|
||||
|
||||
var signingCredentials = new SigningCredentials(signingKey, a);
|
||||
|
||||
var token = new JwtSecurityToken(
|
||||
issuer: configuration["JwT:Issuer"],
|
||||
audience: configuration["JwT:Audience"],//接收
|
||||
claims: claims,//存放的用户信息
|
||||
notBefore: DateTime.UtcNow,//发布时间
|
||||
expires: DateTime.UtcNow.AddHours(12),
|
||||
signingCredentials: signingCredentials
|
||||
//有效期设置为1天signingCredentials //数字名
|
||||
);
|
||||
TokenString = new JwtSecurityTokenHandler().WriteToken(token);
|
||||
return TokenString;
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
[Authorize()]
|
||||
public string Helloooo()
|
||||
{
|
||||
return "hello";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public class LoginData
|
||||
{
|
||||
public string? username { get; set; }
|
||||
public string? password { get; set; }
|
||||
}
|
||||
|
||||
internal class TblUtsManageUser
|
||||
{
|
||||
public object Id { get; internal set; }
|
||||
public bool IsAdmin { get; internal set; }
|
||||
public string? UserName { get; internal set; }
|
||||
}
|
||||
}
|
||||
1765
BLW_Log/Controllers/LowerMachineLogController.cs
Normal file
1765
BLW_Log/Controllers/LowerMachineLogController.cs
Normal file
File diff suppressed because it is too large
Load Diff
40
BLW_Log/Controllers/PMSController.cs
Normal file
40
BLW_Log/Controllers/PMSController.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using static ServiceReference1.blwwsSoapClient;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class PMSController : ControllerBase
|
||||
{
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> PMSCheckIn([FromForm]string Code, [FromForm]string RoomNum, [FromForm]string CheckInTime, [FromForm]string XmlString, [FromForm]string Phone, [FromForm]string IdCard)
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
r.isok = true;
|
||||
r.message = "helloasdfweroewrew";
|
||||
//var binding = new System.ServiceModel.BasicHttpBinding();
|
||||
//var endpoint = new System.ServiceModel.EndpointAddress("http://pms.boonlive-rcu.com:89/blwws.asmx");
|
||||
//ServiceReference1.blwwsSoapClient blw = new ServiceReference1.blwwsSoapClient(binding, endpoint);
|
||||
//DateTime.TryParse(CheckInTime, out DateTime CheckDateTime);
|
||||
//string msg = "";
|
||||
//var result = await blw.CheckInAsync("blw_ws@2015", Code, RoomNum, CheckDateTime, XmlString, msg, Phone, IdCard);
|
||||
//r.isok = true;
|
||||
//r.message = msg;
|
||||
//r.response = result.Body.CheckInResult;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.isok = false;
|
||||
r.message = ex.Message;
|
||||
}
|
||||
return r;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
1213
BLW_Log/Controllers/PanelSelectionController.cs
Normal file
1213
BLW_Log/Controllers/PanelSelectionController.cs
Normal file
File diff suppressed because it is too large
Load Diff
12
BLW_Log/Controllers/PmsPostToolsController.cs
Normal file
12
BLW_Log/Controllers/PmsPostToolsController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class PmsPostToolsController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
180
BLW_Log/Controllers/ProductionlineController.cs
Normal file
180
BLW_Log/Controllers/ProductionlineController.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
using System.Data;
|
||||
using System.Dynamic;
|
||||
using BLW_Log.Models;
|
||||
using BLW_Log.services;
|
||||
using Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ProductionlineController : ControllerBase
|
||||
{
|
||||
|
||||
[HttpPost()]
|
||||
public ReturnInfo ProductionlineSelect([FromBody] QueryDataForm data)
|
||||
{
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
|
||||
string constr = ReadConfig.Instance.ProductionlineSQLConnectionString;
|
||||
var Q = new MySqlConnection(constr);
|
||||
if (Q.State != ConnectionState.Open)
|
||||
{
|
||||
Q.Open();
|
||||
}
|
||||
string h22 = string.Join(",", data.testinfo.Select(name => $"'{name.Replace("'", "''")}'"));
|
||||
string sql = @$"SELECT `ID`,`测试时间`
|
||||
,`测试结果`
|
||||
,`测试信息`
|
||||
,`ADC_LEV_10`
|
||||
,`ADC_LEV_0`
|
||||
,`软件版本号`
|
||||
,`硬件版本号`
|
||||
,`UUID`
|
||||
,`状态机`
|
||||
,`实时值`
|
||||
,`背景值`
|
||||
,`基底值`
|
||||
,`LEL百分比`
|
||||
,`稳定状态`
|
||||
,`温度` FROM `calibrationtest`
|
||||
where `测试时间`>=@testtime_start and `测试时间`<=@testtime_end
|
||||
and `测试信息` in ({h22})
|
||||
";
|
||||
MySqlCommand cmd = new MySqlCommand(sql, Q);
|
||||
|
||||
MySqlParameter pm3 = new("@testtime_start", data.testrange_start);
|
||||
MySqlParameter pm4 = new("@testtime_end", data.testrange_end);
|
||||
cmd.Parameters.Add(pm3);
|
||||
cmd.Parameters.Add(pm4);
|
||||
|
||||
if (data.testresult != "")
|
||||
{
|
||||
sql += " and `测试结果`=@testresult ";
|
||||
MySqlParameter pm1 = new MySqlParameter("@testresult", data.testresult);
|
||||
cmd.Parameters.Add(pm1);
|
||||
}
|
||||
|
||||
cmd.CommandText = sql;
|
||||
MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet);
|
||||
|
||||
DataTable dt = dataSet.Tables[0];
|
||||
|
||||
List<dynamic> list = new List<dynamic>();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
dynamic ddd = new ExpandoObject();
|
||||
ddd.ID = item["ID"].ToString();
|
||||
ddd.TestTime = item["测试时间"].ToString();
|
||||
ddd.TestResult = item["测试结果"].ToString();
|
||||
ddd.TestInfo = item["测试信息"].ToString();
|
||||
ddd.ADC_LEV_10 = item["ADC_LEV_10"].ToString();
|
||||
ddd.ADC_LEV_0 = item["ADC_LEV_0"].ToString();
|
||||
ddd.SoftwareVer = item["软件版本号"].ToString();
|
||||
ddd.HardwareVer = item["硬件版本号"].ToString();
|
||||
ddd.UUID = item["UUID"].ToString();
|
||||
ddd.StateMachine = item["状态机"]?.ToString();
|
||||
ddd.RealtimeVal = item["实时值"]?.ToString();
|
||||
ddd.BackgroundVal = item["背景值"]?.ToString();
|
||||
ddd.BaseVal = item["基底值"]?.ToString();
|
||||
ddd.LelPer = item["LEL百分比"].ToString();
|
||||
ddd.Stabilise = item["稳定状态"].ToString();
|
||||
ddd.Temp = item["温度"].ToString();
|
||||
list.Add(ddd);
|
||||
}
|
||||
}
|
||||
info.isok = true;
|
||||
info.response = list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public ReturnInfo ProductionlineTestInfo()
|
||||
{
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
|
||||
string constr = ReadConfig.Instance.ProductionlineSQLConnectionString;
|
||||
var Q = new MySqlConnection(constr);
|
||||
if (Q.State != ConnectionState.Open)
|
||||
{
|
||||
Q.Open();
|
||||
}
|
||||
string sql = @"SELECT `测试信息` from calibrationtest GROUP BY `测试信息`;";
|
||||
MySqlCommand cmd = new MySqlCommand(sql, Q);
|
||||
|
||||
MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet);
|
||||
DataTable dt = dataSet.Tables[0];
|
||||
List<dynamic> list = new List<dynamic>();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
dynamic ddd = new ExpandoObject();
|
||||
ddd.value = item["测试信息"].ToString();
|
||||
list.Add(ddd);
|
||||
}
|
||||
}
|
||||
info.isok = true;
|
||||
info.response = list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost()]
|
||||
public ReturnInfo Productionline(Dictionary<string, string> dic)
|
||||
{
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
if (dic["key"].Equals("i_love_blw^_^"))
|
||||
{
|
||||
try
|
||||
{
|
||||
MyExcel.TempNewMethod(true);
|
||||
info.isok = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.message = ex.Message;
|
||||
info.isok = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = "你无法这样子操作";
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
public class QueryDataForm
|
||||
{
|
||||
public string testresult { get; set; }
|
||||
public List<string> testinfo { get; set; }
|
||||
public string testrange_start { get; set; }
|
||||
public string testrange_end { get; set; }
|
||||
}
|
||||
}
|
||||
59
BLW_Log/Controllers/RCUController.cs
Normal file
59
BLW_Log/Controllers/RCUController.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class RCUController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录接口
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> Login(LoginData data)
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
dic.Add("username", data.username??"");
|
||||
dic.Add("password", data.password??"");
|
||||
r = await Http.HttpPostSendData(dic, "/api/LogSystemloginNew");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.isok = false;
|
||||
r.response = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取RCU的状态
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GetRCUStatus(dynamic data)
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
dic.Add("code", data.code);
|
||||
dic.Add("creatDate", data.creatDate);
|
||||
dic.Add("roomNumber", data.roomNumber);
|
||||
r = await Http.HttpGetSendData(dic, "/api/GetRCUStatus");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.isok = false;
|
||||
r.response = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
BLW_Log/Controllers/TestMachineLogController.cs
Normal file
12
BLW_Log/Controllers/TestMachineLogController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class TestMachineLogController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
BLW_Log/Controllers/ToolsController.cs
Normal file
12
BLW_Log/Controllers/ToolsController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class ToolsController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
68
BLW_Log/Controllers/TouChuanController.cs
Normal file
68
BLW_Log/Controllers/TouChuanController.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class TouChuanController : ControllerBase
|
||||
{
|
||||
public IMemoryCache _cache { get; set; }
|
||||
|
||||
public TouChuanController(IMemoryCache cache)
|
||||
{
|
||||
this._cache = cache;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> SendUDPPackage([FromBody] Dictionary<string, string> L)
|
||||
{
|
||||
|
||||
//hostnumber
|
||||
//mac
|
||||
//bytelist 命令集,如01020304050a0b
|
||||
//cmdtype 命令类型
|
||||
//isoriginal 是否原始数据 如果这个为true,就不再遵循RCU的协议规范
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
info.isok = true;
|
||||
try
|
||||
{
|
||||
|
||||
ReturnInfo data = await Http.HttpPostFormSendData(L, "api/SendUDPPackage");
|
||||
info.response = data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> SetTouChuanData([FromBody] Dictionary<string, string> L)
|
||||
{
|
||||
|
||||
//hostnumber
|
||||
//mac
|
||||
//add_or_remove
|
||||
ReturnInfo info = new ReturnInfo();
|
||||
info.isok = true;
|
||||
try
|
||||
{
|
||||
|
||||
ReturnInfo data = await Http.HttpPostFormSendData(L, "api/SetTouChuanData");
|
||||
info.response = data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.isok = false;
|
||||
info.message = ex.Message;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
BLW_Log/Controllers/ValuesController.cs
Normal file
32
BLW_Log/Controllers/ValuesController.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Text;
|
||||
using DAL.PGModels;
|
||||
using LinqToDB;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ValuesController : ControllerBase
|
||||
{
|
||||
public string get_json(string data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public string wireshark_json()
|
||||
{
|
||||
var readResult = Request.BodyReader.ReadAsync().Result;
|
||||
Request.BodyReader.AdvanceTo(readResult.Buffer.Start, readResult.Buffer.End);
|
||||
string body = Encoding.UTF8.GetString(readResult.Buffer.FirstSpan);
|
||||
return "";
|
||||
}
|
||||
[HttpPost()]
|
||||
public string HeartCallWake()
|
||||
{
|
||||
return "iam wake up";
|
||||
}
|
||||
}
|
||||
}
|
||||
12
BLW_Log/Controllers/VoiceLogController.cs
Normal file
12
BLW_Log/Controllers/VoiceLogController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class VoiceLogController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
BLW_Log/Controllers/XlsxToolController.cs
Normal file
12
BLW_Log/Controllers/XlsxToolController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BLW_Log.Controllers
|
||||
{
|
||||
public class XlsxToolController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user