using Aliyun.OSS; using DOAN.Model; using DOAN.Model.Business; using DOAN.Model.Dto; using DOAN.Model.MES.process; using DOAN.Repository; using DOAN.Service.Business.IBusinessService; using Infrastructure.Attribute; using Infrastructure.Extensions; using NPOI.SS.Formula.Functions; using NPOI.XSSF.Streaming.Values; using SqlSugar; using System; using System.Linq; namespace DOAN.Service.Business { /// /// Service业务层处理 /// [AppService(ServiceType = typeof(IProcessmodelWorkStepService), ServiceLifetime = LifeTime.Transient)] public class ProcessmodelWorkStepService : BaseService, IProcessmodelWorkStepService { /// /// 查询列表 /// /// /// public PagedInfo GetList(ProcessmodelWorkStepQueryDto parm) { var predicate = Expressionable.Create() .AndIF(!string.IsNullOrEmpty(parm.StepCode), p => parm.StepCode.Contains(p.StepCode)) .AndIF(!string.IsNullOrEmpty(parm.StepName), p => parm.StepName.Contains(p.StepName)); var response = Queryable() .Where(predicate.ToExpression()) .GroupBy(p => p.StepCode) .ToPage(parm); return response; } /// /// 获取详情 /// /// /// public ProcessmodelWorkStep GetInfo(long Id) { var response = Queryable() .Where(x => x.Id == Id) .First(); return response; } /// /// 添加 /// /// /// public ProcessmodelWorkStep AddProcessmodelWorkStep(ProcessmodelWorkStep model) { return Context.Insertable(model).ExecuteReturnEntity(); } /// /// 修改 /// /// /// public int UpdateProcessmodelWorkStep(ProcessmodelWorkStep model) { //var response = Update(w => w.Id == model.Id, it => new ProcessmodelOperationStep() //{ // OperationStepCode = model.OperationStepCode, // OperationStepName = model.OperationStepName, // OperationCode = model.OperationCode, // Description = model.Description, // IsActive = model.IsActive, // UpdateTime = model.UpdateTime, // UpdateBy = model.UpdateBy, // Remark = model.Remark, //}); //return response; return Update(model, true); } public List GetUniqueValueList(string stepCode) { bool stepCodeExists = Context.Queryable() .Any(p => p.StepCode == stepCode); if (!stepCodeExists) { return new List(); } List uniqueValues = Context.Queryable() .Where(p => p.StepCode == stepCode) .Select(p => p.UniqueValue) .Distinct() .Where(uv => !string.IsNullOrEmpty(uv)) .ToList(); var result = Context.Queryable() .Where(d => uniqueValues.Contains(d.UniqueValue)) // 批量匹配,性能优于循环查询 .Select(d => new UniqueValueQueryDto { Value = d.UniqueValue, Name = d.Description }) .ToList(); return result; } public int AddUniqueValue(string stepCode) { throw new NotImplementedException(); } public int DeleteUniqueValue(long id) { throw new NotImplementedException(); } } }