shgx_tz_mom/ZR.Service/mes/andon/AndonAlarmAreaLightDicService.cs
quowingwang 517b3a79d3 安灯
2025-12-24 14:26:46 +08:00

92 lines
3.0 KiB
C#

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
{
/// <summary>
/// 安灯警报区三色灯IP字典Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IAndonAlarmAreaLightDicService), ServiceLifetime = LifeTime.Transient)]
public class AndonAlarmAreaLightDicService : BaseService<AndonAlarmAreaLightDic>, IAndonAlarmAreaLightDicService
{
/// <summary>
/// 查询安灯警报区三色灯IP字典列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<AndonAlarmAreaLightDicDto> GetList(AndonAlarmAreaLightDicQueryDto parm)
{
var predicate = Expressionable.Create<AndonAlarmAreaLightDic>();
if (!string.IsNullOrEmpty(parm.Area1))
{
predicate = predicate.And(x => x.Area1.Contains(parm.Area1));
}
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<AndonAlarmAreaLightDic, AndonAlarmAreaLightDicDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public AndonAlarmAreaLightDic GetInfo(int Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加安灯警报区三色灯IP字典
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public AndonAlarmAreaLightDic AddAndonAlarmAreaLightDic(AndonAlarmAreaLightDic model)
{
if (model.Area2 == null || model.Area2 == "")
{
model.Area2 = "NA";
}
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改安灯警报区三色灯IP字典
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
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);
}
}
}