添加项目文件。
This commit is contained in:
83
MoviconWebApi/API/ClearDataApi/Data.cs
Normal file
83
MoviconWebApi/API/ClearDataApi/Data.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using MoviconWebApi.Entities;
|
||||
|
||||
namespace MoviconWebApi.API.ClearDataApi
|
||||
{
|
||||
public static class Data
|
||||
{
|
||||
internal static async Task<List<ClearDataResponse>?> GetClearData(ClearDataRequest request, IFreeSql freeSql)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 构建查询
|
||||
var query = freeSql.Select<ClearData>();
|
||||
|
||||
// 根据设备编号过滤
|
||||
if (!string.IsNullOrWhiteSpace(request.DeviceCode))
|
||||
{
|
||||
query = query.Where(x => x.DeviceCode == request.DeviceCode);
|
||||
}
|
||||
|
||||
// 根据开始时间过滤
|
||||
if (!string.IsNullOrWhiteSpace(request.StartTime) && DateTime.TryParse(request.StartTime, out DateTime startTime))
|
||||
{
|
||||
query = query.Where(x => x.CreateTime >= startTime);
|
||||
}
|
||||
|
||||
// 根据结束时间过滤
|
||||
if (!string.IsNullOrWhiteSpace(request.EndTime) && DateTime.TryParse(request.EndTime, out DateTime endTime))
|
||||
{
|
||||
query = query.Where(x => x.CreateTime <= endTime);
|
||||
}
|
||||
|
||||
// 按创建时间降序排序
|
||||
query = query.OrderByDescending(x => x.CreateTime);
|
||||
|
||||
// 执行查询并映射到响应模型
|
||||
var result = await query.ToListAsync(x => new ClearDataResponse
|
||||
{
|
||||
DeviceCode = x.DeviceCode,
|
||||
DeviceName = x.DeviceName,
|
||||
program_process = x.program_process,
|
||||
vehicle_model = x.vehicle_model,
|
||||
locomotive_number = x.locomotive_number,
|
||||
repair_process = x.repair_process,
|
||||
component_name = x.component_name,
|
||||
part_position = x.part_position,
|
||||
part_num = x.part_num,
|
||||
part_qrid = x.part_qrid,
|
||||
AgentTank_Level = x.AgentTank_Level,
|
||||
Test_CleaningAgentTankAdd=x.Test_CleaningAgentTankAdd,
|
||||
Test_CleaningAgentTankHeat=x.Test_CleaningAgentTankHeat,
|
||||
Test_FrameworkPerModelCleaningAgentUsage = x.Test_FrameworkPerModelCleaningAgentUsage,
|
||||
Test_FrameworkPerModelWaterUsage = x.Test_FrameworkPerModelWaterUsage,
|
||||
WaterTank_Temp = x.WaterTank_Temp,
|
||||
AgentTank_Temp = x.AgentTank_Temp,
|
||||
SoakingTank1_Temp = x.SoakingTank1_Temp,
|
||||
SoakingTank2_Temp = x.SoakingTank2_Temp,
|
||||
Test_ElectricSurveillance=x.Test_ElectricSurveillance,
|
||||
Test_FrameworkPerModelCleaningDuration=x.Test_FrameworkPerModelCleaningDuration,
|
||||
Test_FrameworkProgramProcess=x.Test_FrameworkProgramProcess,
|
||||
Test_FrameworkProgramProcessPercentage=x.Test_FrameworkProgramProcessPercentage,
|
||||
Test_SteamSurveillance= x.Test_SteamSurveillance,
|
||||
Test_WaterTankAdd= x.Test_WaterTankAdd,
|
||||
Test_WaterTankHeat= x.Test_WaterTankHeat,
|
||||
WaterTank_Level=x.WaterTank_Level,
|
||||
|
||||
CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 记录异常日志(可以根据实际需求添加日志记录)
|
||||
Console.WriteLine($"获取清洗数据失败:{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user