2025-11-15 14:33:00 +08:00
|
|
|
|
2025-11-19 14:56:43 +08:00
|
|
|
using Aliyun.OSS;
|
2025-12-29 18:59:42 +08:00
|
|
|
using DOAN.Model.MES.recipe;
|
|
|
|
|
using DOAN.Model.MES.recipe.Dto;
|
2025-11-15 14:33:00 +08:00
|
|
|
using Infrastructure.Attribute;
|
2025-11-19 14:56:43 +08:00
|
|
|
using Mapster;
|
2025-12-29 16:58:36 +08:00
|
|
|
using MDM.Controllers.Process;
|
2025-11-16 15:16:51 +08:00
|
|
|
using MDM.Model;
|
2025-12-31 18:28:24 +08:00
|
|
|
using MDM.Model.Material;
|
2025-11-16 15:16:51 +08:00
|
|
|
using MDM.Model.Process;
|
|
|
|
|
using MDM.Model.Process.Dto;
|
2025-12-29 16:58:36 +08:00
|
|
|
using MDM.Models.Process;
|
|
|
|
|
using MDM.Models.Process.Dto;
|
2025-11-16 15:16:51 +08:00
|
|
|
using MDM.Repository;
|
|
|
|
|
using MDM.Service;
|
|
|
|
|
using MDM.Services.IProcessService;
|
2025-11-15 14:33:00 +08:00
|
|
|
|
2025-11-16 15:16:51 +08:00
|
|
|
|
|
|
|
|
namespace MDM.Services.Process
|
2025-11-15 14:33:00 +08:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工序Service业务层处理
|
|
|
|
|
/// </summary>
|
|
|
|
|
[AppService(ServiceType = typeof(IProcessOperationService), ServiceLifetime = LifeTime.Transient)]
|
|
|
|
|
public class ProcessOperationService : BaseService<ProcessOperation>, IProcessOperationService
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询工序列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parm"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public PagedInfo<ProcessOperationDto> GetList(ProcessOperationQueryDto parm)
|
|
|
|
|
{
|
2025-11-18 14:49:40 +08:00
|
|
|
var predicate = Expressionable.Create<ProcessOperation>()
|
|
|
|
|
.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))
|
|
|
|
|
|
|
|
|
|
;
|
2025-11-15 14:33:00 +08:00
|
|
|
|
|
|
|
|
var response = Queryable()
|
2025-12-29 16:58:36 +08:00
|
|
|
.Select(it => new ProcessOperation()
|
|
|
|
|
{
|
2025-11-19 15:34:46 +08:00
|
|
|
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<ProcessControlStrategyDict>().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
|
|
|
|
|
|
|
|
|
|
|
2025-12-29 16:58:36 +08:00
|
|
|
}, true)
|
2025-11-15 14:33:00 +08:00
|
|
|
.Where(predicate.ToExpression())
|
|
|
|
|
.ToPage<ProcessOperation, ProcessOperationDto>(parm);
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-12-29 18:59:42 +08:00
|
|
|
/// 获取详情,同时显示工序绑定的流程信息,配方信息
|
2025-11-15 14:33:00 +08:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="OperationId"></param>
|
|
|
|
|
/// <returns></returns>
|
2025-12-29 16:58:36 +08:00
|
|
|
public ProcessOperationInfoDto GetInfo(int OperationId)
|
2025-11-15 14:33:00 +08:00
|
|
|
{
|
|
|
|
|
var response = Queryable()
|
2025-12-29 16:58:36 +08:00
|
|
|
.Where(x => x.OperationId == OperationId)
|
|
|
|
|
.Select(it => new ProcessOperationInfoDto()
|
|
|
|
|
{
|
|
|
|
|
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 = it.ControlStrategy,
|
|
|
|
|
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,
|
2025-12-29 19:34:29 +08:00
|
|
|
//绑定的流程信息
|
2025-12-29 18:59:42 +08:00
|
|
|
OperationFlows = SqlFunc.Subqueryable<ProcessOperationFlow>().Where(s => s.FkRoutingCode == it.FkRoutingCode && s.FkOperationCode == it.OperationCode).ToList(),
|
2025-12-31 11:45:08 +08:00
|
|
|
|
|
|
|
|
////绑定的配方参数信息
|
2025-12-31 20:17:18 +08:00
|
|
|
//OperationRecipeParameters = SqlFunc.Subqueryable<PfRefProductRecipe>()
|
|
|
|
|
//.LeftJoin<PfRecipeVersion>((refpr, ver) => refpr.RecipeCode == ver.RecipeCode)
|
|
|
|
|
//.LeftJoin<PfRecipeParameters>((refpr, ver, param) => ver.RecipeCode == param.RecipeCode && ver.Version == param.Version)
|
|
|
|
|
//.Where((refpr, ver, param) => refpr.FkRoutingCode == it.FkRoutingCode && refpr.FkOperationCode == it.OperationCode)
|
|
|
|
|
//.ToList((refpr, ver, param) => new PfRecipeParametersDto
|
|
|
|
|
//{
|
|
|
|
|
// Id = param.Id,
|
|
|
|
|
// RecipeCode = param.RecipeCode,
|
|
|
|
|
// Version = param.Version,
|
|
|
|
|
// ParamName = param.ParamName,
|
|
|
|
|
// Unit = param.Unit,
|
|
|
|
|
// UpperLimit = param.UpperLimit,
|
|
|
|
|
// LowerLimit = param.LowerLimit,
|
|
|
|
|
// StandardValue = param.StandardValue,
|
|
|
|
|
// Remark = param.Remark
|
|
|
|
|
//}),
|
2025-12-31 20:26:36 +08:00
|
|
|
|
2025-12-31 11:45:08 +08:00
|
|
|
////绑定的采集参数
|
2025-12-31 20:26:36 +08:00
|
|
|
ProcessOperationCollectParameters = SqlFunc.Subqueryable<ProcessOperationCollectParameter>().Where(s => s.FkRoutingCode == it.FkRoutingCode && s.FkOperationCode == it.OperationCode).ToList(),
|
2025-12-29 18:59:42 +08:00
|
|
|
|
2025-12-31 18:37:16 +08:00
|
|
|
// 绑定的物料参数
|
2025-12-31 20:26:36 +08:00
|
|
|
ProcessOperationFlowMaterialParamters = SqlFunc.Subqueryable<ProcessOperationFlowMaterialParamter>().Where(s => s.FkRoutingCode == it.FkRoutingCode && s.FkOperationCode == it.OperationCode).ToList(),
|
2025-12-29 18:59:42 +08:00
|
|
|
|
|
|
|
|
|
2025-12-31 20:26:36 +08:00
|
|
|
}).First();
|
2025-12-29 18:59:42 +08:00
|
|
|
|
2025-11-15 14:33:00 +08:00
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加工序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public ProcessOperation AddProcessOperation(ProcessOperation model)
|
|
|
|
|
{
|
|
|
|
|
return Context.Insertable(model).ExecuteReturnEntity();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改工序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-19 14:56:43 +08:00
|
|
|
public List<ProcessControlStrategyDictDto> SearchControlstrategyDict(ProcessControlStrategyDictQueryDto parm)
|
|
|
|
|
{
|
|
|
|
|
var predicate = Expressionable.Create<ProcessControlStrategyDict>()
|
|
|
|
|
.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<ProcessControlStrategyDict>()
|
|
|
|
|
.Where(predicate.ToExpression())
|
|
|
|
|
.ToList()
|
|
|
|
|
.Adapt<List<ProcessControlStrategyDict>, List<ProcessControlStrategyDictDto>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ProcessOprerationTransitionDict> QueryProcessOprerationTransitionDict(ProcessOprerationTransitionDictQueryDto parm)
|
|
|
|
|
{
|
|
|
|
|
var predicate = Expressionable.Create<ProcessOprerationTransitionDict>()
|
|
|
|
|
.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<ProcessOprerationTransitionDict>()
|
|
|
|
|
.Where(predicate.ToExpression())
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-31 15:57:20 +08:00
|
|
|
public List<ProcessFlowList> GetFlow(string flow_type_code)
|
2025-12-29 16:58:36 +08:00
|
|
|
{
|
|
|
|
|
var response = Context.Queryable<ProcessFlowList>()
|
2025-12-31 15:57:20 +08:00
|
|
|
.WhereIF(!string.IsNullOrEmpty(flow_type_code), m => m.FlowTypeCode.Contains(flow_type_code))
|
2025-12-29 16:58:36 +08:00
|
|
|
.ToList();
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-31 15:58:09 +08:00
|
|
|
|
|
|
|
|
|
2025-12-29 16:58:36 +08:00
|
|
|
public int BindFlow(ProcessOperationBindFlowDto parm)
|
|
|
|
|
{
|
2025-12-31 15:58:09 +08:00
|
|
|
return 0;
|
2025-12-29 16:58:36 +08:00
|
|
|
}
|
2025-12-31 10:27:05 +08:00
|
|
|
public int OperationAddFlow(ProcessOperationFlowDto parm)
|
|
|
|
|
{
|
|
|
|
|
var model = parm.Adapt<ProcessOperationFlowDto, ProcessOperationFlow>();
|
2025-12-31 15:16:17 +08:00
|
|
|
|
2025-12-31 10:27:05 +08:00
|
|
|
model.CreatedTime = DateTime.Now;
|
|
|
|
|
var response = Context.Insertable<ProcessOperationFlow>(model).ExecuteCommand();
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int OperationDeleteFlow(int operation_flow_id)
|
|
|
|
|
{
|
|
|
|
|
var response = Context.Deleteable<ProcessOperationFlow>(m => m.id == operation_flow_id).ExecuteCommand();
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-04 15:33:27 +08:00
|
|
|
public List<ProcessRouting> SelectRouting(string routing)
|
|
|
|
|
{
|
|
|
|
|
var response = Context.Queryable<ProcessRouting>().WhereIF(!string.IsNullOrEmpty(routing), it => it.RoutingCode.Contains(routing)).ToList();
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
|
|
}
|
2025-12-31 16:34:39 +08:00
|
|
|
public List<ProcessOperationFlow> GetOperationFlowList(string routing_code, string operation_code)
|
|
|
|
|
{
|
|
|
|
|
return Context.Queryable<ProcessOperationFlow>().Where(it => it.FkRoutingCode == routing_code && it.FkOperationCode == operation_code).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-31 15:40:54 +08:00
|
|
|
public int OperationAddDatacollection(ProcessOperationCollectParameterDto parm)
|
|
|
|
|
{
|
|
|
|
|
var model = parm.Adapt<ProcessOperationCollectParameterDto, ProcessOperationCollectParameter>();
|
|
|
|
|
model.CreatedTime = DateTime.Now;
|
|
|
|
|
var response = Context.Insertable<ProcessOperationCollectParameter>(model).ExecuteCommand();
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-04 16:35:13 +08:00
|
|
|
public int OperationUpdateFlow(ProcessOperationCollectParameter model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
model.UpdatedTime = DateTime.Now;
|
|
|
|
|
var response = Context.Updateable<ProcessOperationCollectParameter>(model).ExecuteCommand();
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-31 16:15:15 +08:00
|
|
|
public int OperationDeleteDatacollection(int operation_datacollection_id)
|
|
|
|
|
{
|
|
|
|
|
var response = Context.Deleteable<ProcessOperationCollectParameter>(m => m.Id == operation_datacollection_id).ExecuteCommand();
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-31 18:28:24 +08:00
|
|
|
|
|
|
|
|
public List<MaterialList> SearchMaterialInfo(string material_info)
|
|
|
|
|
{
|
2025-12-31 18:29:09 +08:00
|
|
|
|
|
|
|
|
var response = Context.Queryable<MaterialList>()
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(material_info), m => m.Name.Contains(material_info) || m.Code.Contains(material_info))
|
|
|
|
|
.ToList();
|
|
|
|
|
return response;
|
2025-12-31 18:28:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ProcessErrorProofRule> SearchMaterialErrorproofDict(string error_proof_rule_code)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var response = Context.Queryable<ProcessErrorProofRule>()
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(error_proof_rule_code), m => m.ErrorProofRuleCode.Contains(error_proof_rule_code))
|
|
|
|
|
.ToList();
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int OperationAddMaterialParamter(ProcessOperationFlowMaterialParamterDto parm)
|
|
|
|
|
{
|
|
|
|
|
var model = parm.Adapt<ProcessOperationFlowMaterialParamterDto, ProcessOperationFlowMaterialParamter>();
|
|
|
|
|
model.CreatedTime = DateTime.Now;
|
|
|
|
|
var response = Context.Insertable<ProcessOperationFlowMaterialParamter>(model).ExecuteCommand();
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
public int OperationDeleteMaterialParamter(int operation_material_paramter_id)
|
|
|
|
|
{
|
|
|
|
|
var response = Context.Deleteable<ProcessOperationFlowMaterialParamter>(m => m.id == operation_material_paramter_id).ExecuteCommand();
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-31 20:17:18 +08:00
|
|
|
|
|
|
|
|
public PagedInfo<PfRecipeParametersDto> QueryProcessOperationRecipe(ProcessOperationQuery2Dto query)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return Context.Queryable<PfRefProductRecipe>()
|
|
|
|
|
.LeftJoin<PfRecipeVersion>((refpr, ver) => refpr.RecipeCode == ver.RecipeCode)
|
|
|
|
|
.LeftJoin<PfRecipeParameters>((refpr, ver, param) => ver.RecipeCode == param.RecipeCode && ver.Version == param.Version)
|
|
|
|
|
.Where((refpr, ver, param) => refpr.FkRoutingCode == query.FkRoutingCode && refpr.FkOperationCode == query.OperationCode)
|
|
|
|
|
.Select((refpr, ver, param) => new PfRecipeParametersDto
|
|
|
|
|
{
|
|
|
|
|
Id = param.Id,
|
|
|
|
|
RecipeCode = param.RecipeCode,
|
|
|
|
|
Version = param.Version,
|
|
|
|
|
ParamName = param.ParamName,
|
|
|
|
|
Unit = param.Unit,
|
|
|
|
|
UpperLimit = param.UpperLimit,
|
|
|
|
|
LowerLimit = param.LowerLimit,
|
|
|
|
|
StandardValue = param.StandardValue,
|
|
|
|
|
Remark = param.Remark
|
|
|
|
|
}).ToPage<PfRecipeParametersDto, PfRecipeParametersDto>(query);
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-15 14:33:00 +08:00
|
|
|
}
|
|
|
|
|
}
|