using System; using SqlSugar; using Infrastructure.Attribute; using DOAN.Model; using DOAN.Model.MES.product; using DOAN.Model.MES.product.Dto; using DOAN.Repository; using DOAN.Service.MES.product.IService; using System.Linq; namespace DOAN.Service.MES.product { /// /// 生产工单Service业务层处理 /// [AppService(ServiceType = typeof(IProWorkorderService), ServiceLifetime = LifeTime.Transient)] public class ProWorkorderService : BaseService, IProWorkorderService { /// /// 查询生产工单列表 /// /// /// public PagedInfo GetList(ProWorkorderQueryDto parm) { var predicate = Expressionable.Create() .AndIF(!string.IsNullOrEmpty(parm.ProductionName),it=>it.ProductionName.Contains(parm.ProductionName)) .AndIF(!string.IsNullOrEmpty(parm.ProductionCode),it=>it.ProductionCode.Contains(parm.ProductionCode)) .AndIF(!string.IsNullOrEmpty(parm.CustomCode),it=>it.CustomCode.Contains(parm.CustomCode)) .AndIF(parm.WorkorderDate>DateTime.MinValue, it=>it.WorkorderDate== parm.WorkorderDate) .AndIF(parm.Year > 0, it=>it.Year == parm.Year) .AndIF(parm.Week > 0, it=>it.Week == parm.Week) .AndIF(parm.Date > 0, it=>it.Date == parm.Date) ; var response = Queryable() .Where(predicate.ToExpression()) .ToPage(parm); return response; } /// /// 获取详情 /// /// /// public ProWorkorder GetInfo(string Id) { var response = Queryable() .Where(x => x.Id == Id) .First(); return response; } /// /// 添加生产工单 /// /// /// public ProWorkorder AddProWorkorder(ProWorkorder model) { model.Id= SnowFlakeSingle.Instance.NextId().ToString(); return Context.Insertable(model).ExecuteReturnEntity(); } /// /// 修改生产工单 /// /// /// public int UpdateProWorkorder(ProWorkorder model) { var response = Update(w => w.Id == model.Id, it => new ProWorkorder() { ProductionName = model.ProductionName, ProductionCode = model.ProductionCode, CustomCode = model.CustomCode, DeliveryNum = model.DeliveryNum, Unit = model.Unit, PackageNum = model.PackageNum, Sort = model.Sort, WorkorderDate = model.WorkorderDate, Year = model.Year, Week = model.Week, Date = model.Date, Priority = model.Priority, Status = model.Status, Remark = model.Remark, CreatedBy = model.CreatedBy, CreatedTime = model.CreatedTime, UpdatedBy = model.UpdatedBy, UpdatedTime = model.UpdatedTime, }); return response; } } }