using Aliyun.OSS;
using Infrastructure.Attribute;
using Mapster;
using MDM.Model;
using MDM.Model.Process;
using MDM.Model.Process.Dto;
using MDM.Repository;
using MDM.Service;
using MDM.Services.IProcessService;
namespace MDM.Services.Process
{
///
/// 工序Service业务层处理
///
[AppService(ServiceType = typeof(IProcessOperationService), ServiceLifetime = LifeTime.Transient)]
public class ProcessOperationService : BaseService, IProcessOperationService
{
///
/// 查询工序列表
///
///
///
public PagedInfo GetList(ProcessOperationQueryDto parm)
{
var predicate = Expressionable.Create()
.AndIF(!string.IsNullOrEmpty(parm.FkRoutingCode), m => m.FkRoutingCode.Contains(parm.FkRoutingCode))
.AndIF(!string.IsNullOrEmpty(parm.OperationCode), m => m.OperationCode.Contains(parm.OperationCode))
.AndIF(!string.IsNullOrEmpty(parm.OperationName), m => m.OperationName.Contains(parm.OperationName))
.AndIF(!string.IsNullOrEmpty(parm.ParallelGroupCode), m => m.ParallelGroupCode.Contains(parm.ParallelGroupCode))
;
var response = Queryable()
.Select(it=>new ProcessOperation() {
OperationId = it.OperationId,
FkRoutingCode = it.FkRoutingCode,
OperationCode = it.OperationCode,
OperationName = it.OperationName,
OperationSeq = it.OperationSeq,
OperationType = it.OperationType,
Description = it.Description,
StandardTime = it.StandardTime,
ControlStrategy = SqlFunc.Subqueryable().Where(s => s.StrategyCode == it.ControlStrategy).Select(s => s.StrategyName),
IsSkippable = it.IsSkippable,
IsReworkable = it.IsReworkable,
IsParallel = it.IsParallel,
ParallelGroupCode = it.ParallelGroupCode,
DefaultNextOperationCode = it.DefaultNextOperationCode,
Status = it.Status,
CreatedBy = it.CreatedBy,
CreatedTime = it.CreatedTime,
UpdatedBy = it.UpdatedBy,
UpdatedTime = it.UpdatedTime
},true)
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
///
/// 获取详情
///
///
///
public ProcessOperation GetInfo(int OperationId)
{
var response = Queryable()
.Where(x => x.OperationId == OperationId)
.First();
return response;
}
///
/// 添加工序
///
///
///
public ProcessOperation AddProcessOperation(ProcessOperation model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改工序
///
///
///
public int UpdateProcessOperation(ProcessOperation model)
{
//var response = Update(w => w.OperationId == model.OperationId, it => new ProcessOperation()
//{
// FkRoutingCode = model.FkRoutingCode,
// OperationName = model.OperationName,
// OperationSeq = model.OperationSeq,
// OperationType = model.OperationType,
// Description = model.Description,
// StandardTime = model.StandardTime,
// ControlStrategy = model.ControlStrategy,
// IsSkippable = model.IsSkippable,
// IsReworkable = model.IsReworkable,
// IsParallel = model.IsParallel,
// ParallelGroupCode = model.ParallelGroupCode,
// DefaultNextOperationCode = model.DefaultNextOperationCode,
// Status = model.Status,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
public List SearchControlstrategyDict(ProcessControlStrategyDictQueryDto parm)
{
var predicate = Expressionable.Create()
.AndIF(!string.IsNullOrEmpty(parm.StrategyName), m => m.StrategyName.Contains(parm.StrategyName))
.AndIF(!string.IsNullOrEmpty(parm.StrategyCode), m => m.StrategyCode.Contains(parm.StrategyCode))
;
var response = Context.Queryable()
.Where(predicate.ToExpression())
.ToList()
.Adapt, List>();
return response;
}
public List QueryProcessOprerationTransitionDict(ProcessOprerationTransitionDictQueryDto parm)
{
var predicate = Expressionable.Create()
.AndIF(!string.IsNullOrEmpty(parm.TranstionName), m => m.TranstionName.Contains(parm.TranstionName))
.AndIF(!string.IsNullOrEmpty(parm.TransitionCode), m => m.TransitionCode.Contains(parm.TransitionCode))
;
var response = Context.Queryable()
.Where(predicate.ToExpression())
.ToList();
return response;
}
}
}