diff --git a/src/CncRepository/Impl/Log/CollectAnalysisRepository.cs b/src/CncRepository/Impl/Log/CollectAnalysisRepository.cs index 543d539..0a3de53 100644 --- a/src/CncRepository/Impl/Log/CollectAnalysisRepository.cs +++ b/src/CncRepository/Impl/Log/CollectAnalysisRepository.cs @@ -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 }); } } + + /// 按机床ID和日期查询采集分析记录 + public List 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(sql, + new { MachineId = machineId, Date = date }).AsList(); + } + } } } diff --git a/src/CncRepository/Interface/ICollectAnalysisRepository.cs b/src/CncRepository/Interface/ICollectAnalysisRepository.cs index 42b6086..f8524a5 100644 --- a/src/CncRepository/Interface/ICollectAnalysisRepository.cs +++ b/src/CncRepository/Interface/ICollectAnalysisRepository.cs @@ -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 GetAnalysisByRawLogId(long rawLogId); long Create(CollectAnalysis entity); int DeleteBeforeDate(DateTime date); + /// 按机床ID和日期查询采集分析记录 + List GetRecordsByMachineAndDate(int machineId, DateTime date); } }