You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.0 KiB
C#

using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Repository.service.Impl
* 2ef6cbc3-f5ce-4d6a-9750-06aac8227b6f
*
* WenJY
* wenjy@mesnac.com
* 2024-04-07 16:57:02
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Repository.service.Impl
{
public class DmsRecordShutDownServiceImpl : BaseServiceImpl<DmsRecordShutDown>, IDmsRecordShutDownService
{
public DmsRecordShutDownServiceImpl(Repository<DmsRecordShutDown> rep):base(rep)
{
}
/// <summary>
/// 查询每个设备关机记录第一条
/// </summary>
/// <param name="palleCode"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public List<DmsRecordShutDown> GetAllMachineFirst()
{
List<DmsRecordShutDown> list = null;
try
{
string sql = "WITH RankedRecords AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY device_id ORDER BY create_time DESC) AS rn FROM dms_record_shut_down WHERE device_id IN (1016, 1017, 1018, 1019, 1020)) SELECT * FROM RankedRecords WHERE rn = 1;";
list = base._rep.Context.Ado.SqlQuery<DmsRecordShutDown>(sql);
return list;
}
catch (Exception e)
{
return list;
}
}
}
}