feat(后端): CollectAnalysisRepository新增按机床+日期查询采集记录方法(T7数据源切换)

main
haoliang 1 month ago
parent 287281e7b3
commit 71d4947712

@ -5,6 +5,7 @@ using Dapper;
using MySqlConnector;
using CncModels.Dto;
using CncModels.Dto.CollectLog;
using CncModels.Dto.Machine;
using CncModels.Entity;
using CncRepository.Base;
using CncRepository.Interface;
@ -184,5 +185,23 @@ namespace CncRepository.Impl.Log
new { Date = date });
}
}
/// <summary>按机床ID和日期查询采集分析记录</summary>
public List<MachineCollectRecordItem> GetRecordsByMachineAndDate(int machineId, DateTime date)
{
using (var conn = CreateConnection())
{
var sql = @"
SELECT DATE_FORMAT(analysis_time, '%Y-%m-%d %H:%i:%s') AS CollectTime,
current_program AS ProgramName,
current_part_count AS PartCount,
current_status AS RunStatus
FROM log_collect_analysis
WHERE machine_id = @MachineId AND DATE(analysis_time) = @Date
ORDER BY analysis_time DESC";
return conn.Query<MachineCollectRecordItem>(sql,
new { MachineId = machineId, Date = date }).AsList();
}
}
}
}

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using CncModels.Dto;
using CncModels.Dto.CollectLog;
using CncModels.Dto.Machine;
using CncModels.Entity;
namespace CncRepository.Interface
@ -16,5 +17,7 @@ namespace CncRepository.Interface
List<CollectAnalysisListItem> GetAnalysisByRawLogId(long rawLogId);
long Create(CollectAnalysis entity);
int DeleteBeforeDate(DateTime date);
/// <summary>按机床ID和日期查询采集分析记录</summary>
List<MachineCollectRecordItem> GetRecordsByMachineAndDate(int machineId, DateTime date);
}
}

Loading…
Cancel
Save