54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using Infrastructure.Attribute;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ZR.Model.Dto;
|
|
using ZR.Model.MES.andon;
|
|
using ZR.Service.MES.andon.IService;
|
|
|
|
namespace ZR.Service.MES.andon
|
|
{
|
|
[AppService(ServiceType = typeof(IAndonInteractionService), ServiceLifetime = LifeTime.Transient)]
|
|
public class AndonInteractionService : BaseService<AndonFaultRecord>, IAndonInteractionService
|
|
{
|
|
/// <summary>
|
|
/// 呼叫请求
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
public int CallHandle(AndonFaultRecord record)
|
|
{
|
|
record.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
record.StartTime = DateTime.Now;
|
|
record.Status = 1;
|
|
|
|
|
|
return Context.Insertable(record).ExecuteCommand();
|
|
}
|
|
public int SignIn(AndonFaultRecord record)
|
|
{
|
|
if (record.StartTime > DateTime.MinValue && record.EndTime > DateTime.MinValue)
|
|
{
|
|
TimeSpan timeDifference = record.EndTime.Value - record.StartTime.Value;
|
|
record.Duration = (decimal)timeDifference.TotalMinutes;
|
|
}
|
|
else
|
|
{
|
|
record.Duration = 0;
|
|
}
|
|
return Update(record, true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取待响应的 记录
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<AndonFaultRecord> WaitingResponse()
|
|
{
|
|
return Context.Queryable<AndonFaultRecord>().Where(it=>it.Status == 1).ToList();
|
|
}
|
|
}
|
|
}
|