GONGXUSHITIH
This commit is contained in:
parent
1e07f26506
commit
1dee839c7f
@ -59,8 +59,8 @@ namespace MDM.Controllers.Process
|
||||
{
|
||||
var response = _ProcessOperationWorkstationMappingService.GetInfo(Id);
|
||||
|
||||
var info = response.Adapt<ProcessOperationWorkstationMapping>();
|
||||
return SUCCESS(info);
|
||||
// var info = response.Adapt<ProcessOperationWorkstationMapping>();
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -112,6 +112,31 @@ namespace MDM.Controllers.Process
|
||||
}
|
||||
|
||||
|
||||
//TODO 采集参数 实体化 (同步)
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="OperationWorkstationMappingId"></param>
|
||||
/// <returns> int 同步的数据条数</returns>
|
||||
[HttpGet("sync_CollectParameter")]
|
||||
|
||||
public IActionResult SyncCollectParameter(int OperationWorkstationMappingId)
|
||||
{
|
||||
var response = _ProcessOperationWorkstationMappingService.SyncCollectParameter(OperationWorkstationMappingId);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
|
||||
//TODO 添加plc点位
|
||||
[HttpGet("update_plc_point")]
|
||||
public IActionResult UpdatePlcPoint(int ProcessOperationWorkstationFlowCollectParameterId, string plc_point)
|
||||
{
|
||||
var response = _ProcessOperationWorkstationMappingService.UpdatePlcPoint(ProcessOperationWorkstationFlowCollectParameterId, plc_point);
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Models.Process.Dto
|
||||
{
|
||||
public class ProcessOperationWorkstationFlowCollectParameterDto
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工序路线code
|
||||
/// </summary>
|
||||
|
||||
public string FkRoutingCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序code
|
||||
/// </summary>
|
||||
|
||||
public string FkOperationCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生产线体/工作中心code
|
||||
/// </summary>
|
||||
|
||||
public string FkProductlinebodyCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工位ID
|
||||
/// </summary>
|
||||
|
||||
public string FkWorkstationCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 所属流程code
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fk_flow_code")]
|
||||
public string FkFlowCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 所属plc Ip
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fk_plc_ip")]
|
||||
public string FkPlcIp { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 参数名称,如:温度、压力、时间
|
||||
/// </summary>
|
||||
|
||||
public string ParameterCode { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///plc 点位
|
||||
/// </summary>
|
||||
|
||||
public string PlcPoint { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 显示名称(用于UI展示,可和name一样)
|
||||
/// </summary>
|
||||
|
||||
public string ParameterName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数描述,如:模具温度,用于热压工序
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据类型:FLOAT, INT, STRING, BOOL, AI(模拟量输入)等
|
||||
/// </summary>
|
||||
|
||||
public string DataType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位,如:℃、MPa、秒、mm
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标准/目标值(如目标温度 200.0 ℃)
|
||||
/// </summary>
|
||||
|
||||
public decimal StandardValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小允许值(用于报警/校验)
|
||||
/// </summary>
|
||||
|
||||
public decimal MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大允许值(用于报警/校验)
|
||||
/// </summary>
|
||||
|
||||
public decimal MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为控制参数:1=是(如PID控制),0=否(仅采集)
|
||||
/// </summary>
|
||||
|
||||
public int IsControlled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为监控参数(是否采集/显示):1=是,0=否
|
||||
/// </summary>
|
||||
|
||||
public int IsMonitored { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 控制类型(如PID、ON/OFF、手动设定等,可选)
|
||||
/// </summary>
|
||||
|
||||
public string ControlType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认值(如未采集时使用)
|
||||
/// </summary>
|
||||
|
||||
public decimal DefaultValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否必填/必采:1=是,0=否
|
||||
/// </summary>
|
||||
|
||||
public int IsRequired { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数排序(用于UI展示顺序)
|
||||
/// </summary>
|
||||
public int? Sequence { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,5 @@
|
||||
using DOAN.Model.MES.recipe.Dto;
|
||||
using MDM.Models.Process;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MDM.Model.Process.Dto
|
||||
@ -57,5 +59,35 @@ namespace MDM.Model.Process.Dto
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工序工位详情
|
||||
/// </summary>
|
||||
|
||||
public class ProcessOperationWorkstationMappingInfoDto : ProcessOperationWorkstationMappingDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 关联的流程
|
||||
/// </summary>
|
||||
public List<ProcessOperationFlow> OperationFlows { set; get; }
|
||||
/// <summary>
|
||||
/// 关联的配方及其配方参数
|
||||
/// </summary>
|
||||
public List<PfRecipeParametersDto> OperationRecipeParameters { set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 关联的采集参数
|
||||
/// </summary>
|
||||
public List<ProcessOperationWorkstationFlowCollectParameter> ProcessOperationWorkstationCollectParameters { set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 关联的物料参数
|
||||
/// </summary>
|
||||
public List<ProcessOperationFlowMaterialParamter> ProcessOperationFlowMaterialParamters { set; get; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Models.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// 工艺参数实体化工位表(如温度、压力、时间等,关联工艺路线与工序)
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
[SugarTable("process_operation_workstation_flow_collect_parameter")]
|
||||
public class ProcessOperationWorkstationFlowCollectParameter
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序路线code
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fk_routing_code")]
|
||||
public string FkRoutingCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序code
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fk_operation_code")]
|
||||
public string FkOperationCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生产线体/工作中心code
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fk_productlinebody_code")]
|
||||
public string FkProductlinebodyCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工位ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fk_workstation_code")]
|
||||
public string FkWorkstationCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 所属流程code
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fk_flow_code")]
|
||||
public string FkFlowCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 所属plc Ip
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fk_plc_ip")]
|
||||
public string FkPlcIp { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 参数名称,如:温度、压力、时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "parameter_code")]
|
||||
public string ParameterCode { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///plc 点位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "plc_point")]
|
||||
public string PlcPoint { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 显示名称(用于UI展示,可和name一样)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "parameter_name")]
|
||||
public string ParameterName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数描述,如:模具温度,用于热压工序
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据类型:FLOAT, INT, STRING, BOOL, AI(模拟量输入)等
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "data_type")]
|
||||
public string DataType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位,如:℃、MPa、秒、mm
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标准/目标值(如目标温度 200.0 ℃)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "standard_value")]
|
||||
public decimal StandardValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小允许值(用于报警/校验)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "min_value")]
|
||||
public decimal MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大允许值(用于报警/校验)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "max_value")]
|
||||
public decimal MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为控制参数:1=是(如PID控制),0=否(仅采集)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_controlled")]
|
||||
public int IsControlled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为监控参数(是否采集/显示):1=是,0=否
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_monitored")]
|
||||
public int IsMonitored { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 控制类型(如PID、ON/OFF、手动设定等,可选)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "control_type")]
|
||||
public string ControlType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认值(如未采集时使用)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "default_value")]
|
||||
public decimal DefaultValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否必填/必采:1=是,0=否
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_required")]
|
||||
public int IsRequired { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数排序(用于UI展示顺序)
|
||||
/// </summary>
|
||||
public int? Sequence { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "created_time")]
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "created_by")]
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "updated_time")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "updated_by")]
|
||||
public string UpdatedBy { get; set; }
|
||||
}
|
||||
}
|
||||
@ -19,5 +19,10 @@ namespace MDM.Services.IProcessService
|
||||
|
||||
int UpdateProcessOperationWorkstationMapping(ProcessOperationWorkstationMapping parm);
|
||||
|
||||
|
||||
int SyncCollectParameter(int OperationWorkstationMappingId);
|
||||
|
||||
int UpdatePlcPoint(int ProcessOperationWorkstationFlowCollectParameterId, string plc_point);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
|
||||
using DOAN.Model.MES.recipe;
|
||||
using DOAN.Model.MES.recipe.Dto;
|
||||
using Infrastructure.Attribute;
|
||||
using MDM.Model;
|
||||
using MDM.Model.Process;
|
||||
using MDM.Model.Process.Dto;
|
||||
using MDM.Models.Process;
|
||||
using MDM.Repository;
|
||||
using MDM.Service;
|
||||
using MDM.Services.IProcessService;
|
||||
@ -43,11 +46,57 @@ namespace MDM.Services.Process
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public ProcessOperationWorkstationMapping GetInfo(int Id)
|
||||
public ProcessOperationWorkstationMappingInfoDto GetInfo(int Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
.Where(x => x.Id == Id)
|
||||
.Select(it => new ProcessOperationWorkstationMappingInfoDto()
|
||||
{
|
||||
Id = it.Id,
|
||||
FkRoutingCode = it.FkRoutingCode,
|
||||
FkProductlinebodyCode = it.FkProductlinebodyCode,
|
||||
FkOperationCode = it.FkOperationCode,
|
||||
FkWorkstationCode = it.FkWorkstationCode,
|
||||
IsActive = it.IsActive,
|
||||
Priority = it.Priority,
|
||||
StandardTime = it.StandardTime,
|
||||
SetupTime = it.SetupTime,
|
||||
CreatedTime = it.CreatedTime,
|
||||
CreatedBy = it.CreatedBy,
|
||||
Remark = it.Remark,
|
||||
UpdatedTime = it.UpdatedTime,
|
||||
UpdatedBy = it.UpdatedBy,
|
||||
|
||||
|
||||
//绑定的流程信息
|
||||
OperationFlows = SqlFunc.Subqueryable<ProcessOperationFlow>().Where(s => s.FkRoutingCode == it.FkRoutingCode && s.FkOperationCode == it.FkOperationCode).ToList(),
|
||||
|
||||
////绑定的配方参数信息
|
||||
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.FkOperationCode)
|
||||
.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
|
||||
}),
|
||||
////绑定的工序工位采集参数
|
||||
ProcessOperationWorkstationCollectParameters = SqlFunc.Subqueryable<ProcessOperationWorkstationFlowCollectParameter>().Where(s => s.FkRoutingCode == it.FkRoutingCode && s.FkOperationCode == it.FkOperationCode&&s.FkProductlinebodyCode==it.FkProductlinebodyCode&&s.FkWorkstationCode==it.FkWorkstationCode).ToList(),
|
||||
|
||||
// 绑定的物料参数
|
||||
ProcessOperationFlowMaterialParamters = SqlFunc.Subqueryable<ProcessOperationFlowMaterialParamter>().Where(s => s.FkRoutingCode == it.FkRoutingCode && s.FkOperationCode == it.FkOperationCode).ToList(),
|
||||
|
||||
|
||||
})
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
@ -87,5 +136,86 @@ namespace MDM.Services.Process
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 采集参数 实体化 (同步)
|
||||
/// </summary>
|
||||
/// <param name="OperationWorkstationMappingId"></param>
|
||||
/// <returns></returns>
|
||||
public int SyncCollectParameter(int OperationWorkstationMappingId)
|
||||
{
|
||||
int result = 0;
|
||||
//获取工序工位映射信息
|
||||
ProcessOperationWorkstationMapping selectMapping = Context.Queryable<ProcessOperationWorkstationMapping>().Where(it => it.Id == OperationWorkstationMappingId).First();
|
||||
if(selectMapping!=null&&!string.IsNullOrEmpty(selectMapping.FkRoutingCode) && !string.IsNullOrEmpty(selectMapping.FkOperationCode))
|
||||
{
|
||||
// 获取工序的采集参数
|
||||
List<ProcessOperationCollectParameter> ProcessOperationCollectParameterList = Context.Queryable<ProcessOperationCollectParameter>()
|
||||
.Where(it => it.FkRoutingCode == selectMapping.FkRoutingCode && it.FkOperationCode == selectMapping.FkOperationCode).ToList();
|
||||
|
||||
//同步
|
||||
if (ProcessOperationCollectParameterList != null && ProcessOperationCollectParameterList.Count > 0)
|
||||
{
|
||||
List<ProcessOperationWorkstationFlowCollectParameter> insertData = new List<ProcessOperationWorkstationFlowCollectParameter>();
|
||||
foreach (var parameter in ProcessOperationCollectParameterList)
|
||||
{
|
||||
//判断是否存在
|
||||
int count = Context.Queryable<ProcessOperationWorkstationFlowCollectParameter>()
|
||||
.Where(it => it.FkRoutingCode == parameter.FkRoutingCode
|
||||
&& it.FkOperationCode == parameter.FkOperationCode
|
||||
&& it.ParameterCode == parameter.ParameterCode)
|
||||
.Count();
|
||||
if (count == 0)
|
||||
{
|
||||
//不存在则添加
|
||||
ProcessOperationWorkstationFlowCollectParameter newEntity = new ProcessOperationWorkstationFlowCollectParameter()
|
||||
{
|
||||
FkRoutingCode = parameter.FkRoutingCode,
|
||||
FkOperationCode = parameter.FkOperationCode,
|
||||
FkProductlinebodyCode = selectMapping.FkProductlinebodyCode,
|
||||
FkWorkstationCode = selectMapping.FkWorkstationCode,
|
||||
ParameterCode = parameter.ParameterCode,
|
||||
ParameterName = parameter.ParameterName,
|
||||
Description = parameter.Description,
|
||||
DataType = parameter.DataType,
|
||||
Unit = parameter.Unit,
|
||||
StandardValue = parameter.StandardValue,
|
||||
MinValue = parameter.MinValue,
|
||||
MaxValue = parameter.MaxValue,
|
||||
IsControlled = parameter.IsControlled,
|
||||
IsMonitored = parameter.IsMonitored,
|
||||
ControlType = parameter.ControlType,
|
||||
DefaultValue = parameter.DefaultValue,
|
||||
IsRequired = parameter.IsRequired,
|
||||
Sequence = parameter.Sequence,
|
||||
CreatedTime = DateTime.Now,
|
||||
CreatedBy = "SystemSync"
|
||||
};
|
||||
insertData.Add(newEntity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (insertData.Count > 0)
|
||||
{
|
||||
result = Context.Insertable<ProcessOperationWorkstationFlowCollectParameter>(insertData).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public int UpdatePlcPoint( int ProcessOperationWorkstationFlowCollectParameterId, string plc_point)
|
||||
{
|
||||
return Context.Updateable<ProcessOperationWorkstationFlowCollectParameter>()
|
||||
.SetColumns(it => new ProcessOperationWorkstationFlowCollectParameter() { PlcPoint = plc_point })
|
||||
.Where(it => it.Id == ProcessOperationWorkstationFlowCollectParameterId)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user