using Infrastructure.Attribute;
using Infrastructure.Model;
using SqlSugar;
using ZR.Model;
using ZR.Model.MES.andon;
using ZR.Model.MES.andon.Dto;
using ZR.Repository;
using ZR.Service.mes.andon.Iservice;
namespace ZR.Service.mes.andon
{
///
/// 安灯警报区三色灯IP字典Service业务层处理
///
[AppService(ServiceType = typeof(IAndonAlarmAreaLightDicService), ServiceLifetime = LifeTime.Transient)]
public class AndonAlarmAreaLightDicService : BaseService, IAndonAlarmAreaLightDicService
{
///
/// 查询安灯警报区三色灯IP字典列表
///
///
///
public PagedInfo GetList(AndonAlarmAreaLightDicQueryDto parm)
{
var predicate = Expressionable.Create();
if (!string.IsNullOrEmpty(parm.Area1))
{
predicate = predicate.And(x => x.Area1.Contains(parm.Area1));
}
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
///
/// 获取详情
///
///
///
public AndonAlarmAreaLightDic GetInfo(int Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
///
/// 添加安灯警报区三色灯IP字典
///
///
///
public AndonAlarmAreaLightDic AddAndonAlarmAreaLightDic(AndonAlarmAreaLightDic model)
{
if (model.Area2 == null || model.Area2 == "")
{
model.Area2 = "NA";
}
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改安灯警报区三色灯IP字典
///
///
///
public int UpdateAndonAlarmAreaLightDic(AndonAlarmAreaLightDic model)
{
//var response = Update(w => w.Id == model.Id, it => new AndonAlarmAreaLightDic()
//{
// Area1 = model.Area1,
// Area2 = model.Area2,
// Lightip = model.Lightip,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
if (model.Area2 == null || model.Area2 == "")
{
model.Area2 = "NA";
}
return Update(model, true);
}
}
}