using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using DOAN.Model;
using DOAN.Repository;
using System.Linq;
using DOAN.Model.MES.dev;
using DOAN.Model.MES.dev.Dto;
using DOAN.Service.MES.dev.IService;
using System.Xml.Linq;
namespace DOAN.Service.MES.dev
{
///
/// 点检任务Service业务层处理
///
[AppService(ServiceType = typeof(IDevicePointInspectionPlanService), ServiceLifetime = LifeTime.Transient)]
public class DevicePointInspectionPlanService : BaseService, IDevicePointInspectionPlanService
{
///
/// 查询点检任务列表
///
///
///
public PagedInfo GetList(DevicePointInspectionPlanQueryDto parm)
{
var predicate = Expressionable.Create()
.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name.Contains(parm.Name))
.AndIF(parm.Status > -1, it => it.Status == parm.Status)
.AndIF(parm.Starttime != null, it => it.CreatedTime >= parm.Starttime)
.AndIF(parm.Endtime != null, it => it.CreatedTime <= parm.Endtime)
.AndIF(parm.InnerType > -1, it => it.InnerType == parm.InnerType);
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
///
/// 获取详情
///
///
///
public DevicePointInspectionPlan GetInfo(string Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
///
/// 添加点检任务
///
///
///
public DevicePointInspectionPlan AddDevicePointInspectionPlan(DevicePointInspectionPlan model)
{
model.Id = SnowFlakeSingle.Instance.NextId().ToString();
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改点检任务
///
///
///
public int UpdateDevicePointInspectionPlan(DevicePointInspectionPlan model)
{
//var response = Update(w => w.Id == model.Id, it => new DevicePointInspectionPlan()
//{
// Name = model.Name,
// Status = model.Status,
// Type = model.Type,
// Remark = model.Remark,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
}
}