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.
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using Models;
|
|
using Sln.Imm.Daemon.Model.dao;
|
|
using Sln.Imm.Daemon.Repository.service.@base;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices.JavaScript;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Sln.Imm.Daemon.Repository.service.Impl
|
|
{
|
|
public class BaseDeviceAlarmValServiceImpl : BaseServiceImpl<BaseDeviceAlarmVal>, IBaseDeviceAlarmValService
|
|
{
|
|
public BaseDeviceAlarmValServiceImpl(Repository<BaseDeviceAlarmVal> rep) : base(rep)
|
|
{
|
|
}
|
|
|
|
public bool UpdateAlarmVal(int id)
|
|
{
|
|
try
|
|
{
|
|
// 1. 根据设备ID和开始时间查找报警记录
|
|
var alarmRecord = _rep.AsQueryable()
|
|
.Where(x => x.DEVICE_ID == id &&
|
|
x.CONTINUE_TIME == 0)
|
|
.First();
|
|
if (alarmRecord == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
DateTime endTime = DateTime.Now;
|
|
alarmRecord.ALARM_END_TIME = endTime;
|
|
if (alarmRecord.ALARM_BEGIN_TIME != null)
|
|
{
|
|
//2.计算时长
|
|
DateTime startTime = (DateTime)alarmRecord.ALARM_BEGIN_TIME;
|
|
TimeSpan continueTime = endTime - startTime;
|
|
int totalMinutes = (int)Math.Round(continueTime.TotalMinutes);
|
|
alarmRecord.CONTINUE_TIME = totalMinutes;
|
|
}
|
|
|
|
bool result = _rep.Update(alarmRecord);
|
|
return result;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|