129 lines
4.4 KiB
C#
129 lines
4.4 KiB
C#
|
|
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
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// Service业务层处理
|
||
|
|
/// </summary>
|
||
|
|
[AppService(ServiceType = typeof(IProcessmodelWorkStepService), ServiceLifetime = LifeTime.Transient)]
|
||
|
|
public class ProcessmodelWorkStepService : BaseService<ProcessmodelWorkStep>, IProcessmodelWorkStepService
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 查询列表
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="parm"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
public PagedInfo<ProcessmodeWorkStepDto> GetList(ProcessmodelWorkStepQueryDto parm)
|
||
|
|
{
|
||
|
|
var predicate = Expressionable.Create<ProcessmodelWorkStep>()
|
||
|
|
.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<ProcessmodelWorkStep, ProcessmodeWorkStepDto>(parm);
|
||
|
|
|
||
|
|
return response;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获取详情
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="Id"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
public ProcessmodelWorkStep GetInfo(long Id)
|
||
|
|
{
|
||
|
|
var response = Queryable()
|
||
|
|
.Where(x => x.Id == Id)
|
||
|
|
.First();
|
||
|
|
|
||
|
|
return response;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 添加
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="model"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
public ProcessmodelWorkStep AddProcessmodelWorkStep(ProcessmodelWorkStep model)
|
||
|
|
{
|
||
|
|
return Context.Insertable(model).ExecuteReturnEntity();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 修改
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="model"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
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<UniqueValueQueryDto> GetUniqueValueList(string stepCode)
|
||
|
|
{
|
||
|
|
bool stepCodeExists = Context.Queryable<ProcessmodelWorkStep>()
|
||
|
|
.Any(p => p.StepCode == stepCode);
|
||
|
|
|
||
|
|
if (!stepCodeExists)
|
||
|
|
{
|
||
|
|
return new List<UniqueValueQueryDto>();
|
||
|
|
}
|
||
|
|
|
||
|
|
List<string> uniqueValues = Context.Queryable<ProcessmodelWorkStep>()
|
||
|
|
.Where(p => p.StepCode == stepCode)
|
||
|
|
.Select(p => p.UniqueValue)
|
||
|
|
.Distinct()
|
||
|
|
.Where(uv => !string.IsNullOrEmpty(uv))
|
||
|
|
.ToList();
|
||
|
|
|
||
|
|
var result = Context.Queryable<ProcessmodelDictionary>()
|
||
|
|
.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();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|