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
1.9 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* 版权所有 (c) 2025 WenJY 保留所有权利。
* CLR版本4.0.30319.42000
* 机器名称Mr.Wen's MacBook Pro
* 命名空间Sln.Iot.Repository.service.Impl
* 唯一标识83CD1830-F4B4-49D3-A5A6-A5932F8AD185
*
* 创建者WenJY
* 电子邮箱:
* 创建时间2025-05-27 14:06:04
* 版本V1.0.0
* 描述:
*
*--------------------------------------------------------------------
* 修改人:
* 时间:
* 修改说明:
*
* 版本V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Sln.Iot.Model.dao;
using Sln.Iot.Repository.service.@base;
namespace Sln.Iot.Repository.service.Impl
{
public class DeviceRecordServiceImpl: BaseServiceImpl<DeviceRecord>, IDeviceRecordService
{
public DeviceRecordServiceImpl(Repository<DeviceRecord> rep) : base(rep)
{
}
public bool UpdateCloseTime(DeviceRecord deviceRecord, out List<long> resIds)
{
resIds = new List<long>();
var info = _rep.GetList(x=> x.deviceCode == deviceRecord.deviceCode && x.useState == '1').FirstOrDefault();
if (info != null)
{
resIds.Add(info.objid);
info.closeTime = deviceRecord.closeTime;
info.useState = deviceRecord.useState;
info.useTime = CalculateHoursDifference(info.openTime, deviceRecord.closeTime);
_rep.Update(info);
}
return false;
}
private decimal CalculateHoursDifference(DateTime startTime, DateTime endTime)
{
TimeSpan duration = endTime - startTime;
return Convert.ToDecimal(duration.TotalHours);
}
}
}