PLC表变更
This commit is contained in:
parent
dbf4a54a91
commit
08d8134b98
@ -1,5 +1,6 @@
|
||||
|
||||
using RIZO.Model;
|
||||
using MDM.Model;
|
||||
using MiniExcelLibs.Attributes;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace RIZO.Admin.WebApi.PLC.Model.Dto
|
||||
@ -7,15 +8,8 @@ namespace RIZO.Admin.WebApi.PLC.Model.Dto
|
||||
/// <summary>
|
||||
/// 产线PLC生产参数数据表查询对象
|
||||
/// </summary>
|
||||
public class PlcProductionDataQueryDto : PagerInfo
|
||||
public class PlcProductionDataQueryDto : PagerInfo
|
||||
{
|
||||
public DateTime? startTime { get; set; }
|
||||
public DateTime? endTime { get; set; }
|
||||
public string? ProductCode { get; set; }
|
||||
public string? ProductName { get; set; }
|
||||
public string? PartCode { get; set; }
|
||||
public string? PartName { get; set; }
|
||||
public string? ReworkFlag { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -27,17 +21,13 @@ namespace RIZO.Admin.WebApi.PLC.Model.Dto
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? LineCode { get; set; }
|
||||
public string? WorkstationCode { get; set; }
|
||||
|
||||
public string? PlcIp { get; set; }
|
||||
|
||||
public string? ProductCode { get; set; }
|
||||
|
||||
public string? ProductName { get; set; }
|
||||
|
||||
public string? ProductModel { get; set; }
|
||||
|
||||
public string? WorkstationName { get; set; }
|
||||
|
||||
public string? ParamName { get; set; }
|
||||
|
||||
public string? ParamValue { get; set; }
|
||||
@ -49,19 +39,9 @@ namespace RIZO.Admin.WebApi.PLC.Model.Dto
|
||||
public string? ReworkFlag { get; set; }
|
||||
|
||||
public int? ProductionCycle { get; set; }
|
||||
public int? AutoManual { get; set; }
|
||||
public int? RunStatus { get; set; }
|
||||
public string? TrayNo { get; set; }
|
||||
public string? ProduceModel { get; set; }
|
||||
|
||||
public string? OnlineStatus { get; set; }
|
||||
|
||||
public string? Remark { get; set; }
|
||||
|
||||
public string? SN1 { get; set; }
|
||||
public string? SN2 { get; set; }
|
||||
public string? CameraResult { get; set; }
|
||||
|
||||
public string? CreatedBy { get; set; }
|
||||
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
@ -70,7 +50,113 @@ namespace RIZO.Admin.WebApi.PLC.Model.Dto
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
public int? Automanual { get; set; }
|
||||
|
||||
public int? Runstatus { get; set; }
|
||||
|
||||
public string? TrayNo { get; set; }
|
||||
|
||||
public string? ProduceModel { get; set; }
|
||||
|
||||
public string? OnlineStatus { get; set; }
|
||||
|
||||
public string? WorkstationCode { get; set; }
|
||||
|
||||
public string? ProductModel { get; set; }
|
||||
|
||||
public string? WorkstationName { get; set; }
|
||||
|
||||
public string? Sn1 { get; set; }
|
||||
|
||||
public string? Sn2 { get; set; }
|
||||
|
||||
public string? CameraResult { get; set; }
|
||||
|
||||
public string? AssemblyHousingSN { get; set; }
|
||||
|
||||
public string? AssemblyPCBSN { get; set; }
|
||||
|
||||
public string? TightenHousingSN { get; set; }
|
||||
|
||||
public string? TightenPCBSN { get; set; }
|
||||
|
||||
public string? AssemblyTrayNo { get; set; }
|
||||
|
||||
public string? TightenTrayNo { get; set; }
|
||||
|
||||
public string? Screw1Result { get; set; }
|
||||
|
||||
public string? Screw1Torque { get; set; }
|
||||
|
||||
public string? Screw1Depth { get; set; }
|
||||
|
||||
public string? Screw1Angle { get; set; }
|
||||
|
||||
public string? Screw1TightenTime { get; set; }
|
||||
|
||||
public string? Screw2Result { get; set; }
|
||||
|
||||
public string? Screw2Torque { get; set; }
|
||||
|
||||
public string? Screw2Depth { get; set; }
|
||||
|
||||
public string? Screw2Angle { get; set; }
|
||||
|
||||
public string? Screw2TightenTime { get; set; }
|
||||
|
||||
public string? Screw3Result { get; set; }
|
||||
|
||||
public string? Screw3Torque { get; set; }
|
||||
|
||||
public string? Screw3Depth { get; set; }
|
||||
|
||||
public string? Screw3Angle { get; set; }
|
||||
|
||||
public string? Screw3TightenTime { get; set; }
|
||||
|
||||
public string? Screw4Result { get; set; }
|
||||
|
||||
public string? Screw4Torque { get; set; }
|
||||
|
||||
public string? Screw4Depth { get; set; }
|
||||
|
||||
public string? Screw4Angle { get; set; }
|
||||
|
||||
public string? Screw4TightenTime { get; set; }
|
||||
|
||||
public string? Screw5Result { get; set; }
|
||||
|
||||
public string? Screw5Torque { get; set; }
|
||||
|
||||
public string? Screw5Depth { get; set; }
|
||||
|
||||
public string? Screw5Angle { get; set; }
|
||||
|
||||
public string? Screw5TightenTime { get; set; }
|
||||
|
||||
public string? Screw6Result { get; set; }
|
||||
|
||||
public string? Screw6Torque { get; set; }
|
||||
|
||||
public string? Screw6Depth { get; set; }
|
||||
|
||||
public string? Screw6Angle { get; set; }
|
||||
|
||||
public string? Screw6TightenTime { get; set; }
|
||||
|
||||
public string? Screw7Result { get; set; }
|
||||
|
||||
public string? Screw7Torque { get; set; }
|
||||
|
||||
public string? Screw7Depth { get; set; }
|
||||
|
||||
public string? Screw7Angle { get; set; }
|
||||
|
||||
public string? Screw7TightenTime { get; set; }
|
||||
|
||||
|
||||
|
||||
[ExcelColumn(Name = "运行状态:1=空闲,2=运行中,3=故障;")]
|
||||
public string? RunstatusLabel { get; set; }
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@ namespace RIZO.Admin.WebApi.PLC.Model
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
[SugarColumn(IsPrimaryKey = false, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -21,18 +21,6 @@ namespace RIZO.Admin.WebApi.PLC.Model
|
||||
[SugarColumn(ColumnName = "line_code")]
|
||||
public string LineCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工站编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workstationCode")]
|
||||
public string WorkstationCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工站名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workstationName")]
|
||||
public string WorkstationName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PLC IP地址
|
||||
/// </summary>
|
||||
@ -51,12 +39,6 @@ namespace RIZO.Admin.WebApi.PLC.Model
|
||||
[SugarColumn(ColumnName = "product_name")]
|
||||
public string ProductName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品型号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "product_model")]
|
||||
public string ProductModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数名称
|
||||
/// </summary>
|
||||
@ -76,7 +58,7 @@ namespace RIZO.Admin.WebApi.PLC.Model
|
||||
public DateTime? OccurTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合格标志:0-默认,1-合格,2-不合格
|
||||
/// 合格标志:站位结果1,OK,2,NG
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "qualification_flag")]
|
||||
public string QualificationFlag { get; set; }
|
||||
@ -93,38 +75,10 @@ namespace RIZO.Admin.WebApi.PLC.Model
|
||||
[SugarColumn(ColumnName = "production_cycle")]
|
||||
public int? ProductionCycle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备自动手动:0-自动,1-手动
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "automanual")]
|
||||
public int? AutoManual { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 运行状态:1=空闲,2=运行中,3=故障;
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "runstatus")]
|
||||
public int? RunStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 托盘号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "trayNo")]
|
||||
public string TrayNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产模式
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "produceModel")]
|
||||
public string ProduceModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备在线状态1=离线,0=在线
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "onlineStatus")]
|
||||
public string OnlineStatus { get; set; }
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "remark")]
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -151,6 +105,54 @@ namespace RIZO.Admin.WebApi.PLC.Model
|
||||
[SugarColumn(ColumnName = "uPDATED_TIME")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备模式:0-自动,1-手动
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "automanual")]
|
||||
public int? Automanual { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 运行状态:1=空闲,2=运行中,3=故障;
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "runstatus")]
|
||||
public int? Runstatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 托盘号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "trayNo")]
|
||||
public string TrayNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产模式模式(1:正常模式;2:清线模式;4:返工模式;8:换型模式;16:预热模式)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "produceModel")]
|
||||
public string ProduceModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备在线状态1=离线,0=在线
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "onlineStatus")]
|
||||
public string OnlineStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工站编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workstationCode")]
|
||||
public string WorkstationCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品型号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "productModel")]
|
||||
public string ProductModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工站名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workstationName")]
|
||||
public string WorkstationName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码查询
|
||||
/// </summary>
|
||||
@ -164,10 +166,256 @@ namespace RIZO.Admin.WebApi.PLC.Model
|
||||
public string SN2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 相机结果1,OK,2,NG
|
||||
/// 相机结果1,OK,2,NG
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "cameraResult")]
|
||||
public string CameraResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合装位机壳 SN
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "AssemblyHousingSN")]
|
||||
public string AssemblyHousingSN { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合装位 PCB SN
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "AssemblyPCBSN")]
|
||||
public string AssemblyPCBSN { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧位机壳 SN
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TightenHousingSN")]
|
||||
public string TightenHousingSN { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧位 PCB SN
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TightenPCBSN")]
|
||||
public string TightenPCBSN { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 合装位托盘号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "AssemblyTrayNo")]
|
||||
public string AssemblyTrayNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧位托盘号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TightenTrayNo")]
|
||||
public string TightenTrayNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 1 号螺钉拧紧结果(1 = 合格,0 = 不合格)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw1Result")]
|
||||
public string Screw1Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 1 号螺钉扭矩Nm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw1Torque")]
|
||||
public string Screw1Torque { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 1 号螺钉深度mm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw1Depth")]
|
||||
public string Screw1Depth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 1 号螺钉角度°
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw1Angle")]
|
||||
public string Screw1Angle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 1 号螺钉拧紧时间秒
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw1TightenTime")]
|
||||
public string Screw1TightenTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 2 号螺钉拧紧结果(1 = 合格,0 = 不合格)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw2Result")]
|
||||
public string Screw2Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 2 号螺钉扭矩Nm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw2Torque")]
|
||||
public string Screw2Torque { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 2号螺钉深度mm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw2Depth")]
|
||||
public string Screw2Depth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 2号螺钉角度°
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw2Angle")]
|
||||
public string Screw2Angle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 2 号螺钉拧紧时间秒
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw2TightenTime")]
|
||||
public string Screw2TightenTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 3 号螺钉拧紧结果(1 = 合格,0 = 不合格)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw3Result")]
|
||||
public string Screw3Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 3 号螺钉扭矩Nm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw3Torque")]
|
||||
public string Screw3Torque { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 3 号螺钉深度mm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw3Depth")]
|
||||
public string Screw3Depth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 3 号螺钉角度°
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw3Angle")]
|
||||
public string Screw3Angle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 3号螺钉拧紧时间秒
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw3TightenTime")]
|
||||
public string Screw3TightenTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 4号螺钉拧紧结果(1 = 合格,0 = 不合格)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw4Result")]
|
||||
public string Screw4Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 4号螺钉扭矩Nm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw4Torque")]
|
||||
public string Screw4Torque { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 4号螺钉深度mm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw4Depth")]
|
||||
public string Screw4Depth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 4 号螺钉角度°
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw4Angle")]
|
||||
public string Screw4Angle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 4号螺钉拧紧时间秒
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw4TightenTime")]
|
||||
public string Screw4TightenTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 5 号螺钉拧紧结果(1 = 合格,0 = 不合格)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw5Result")]
|
||||
public string Screw5Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 5号螺钉扭矩Nm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw5Torque")]
|
||||
public string Screw5Torque { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 5号螺钉深度mm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw5Depth")]
|
||||
public string Screw5Depth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 5 号螺钉角度°
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw5Angle")]
|
||||
public string Screw5Angle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 5号螺钉拧紧时间秒
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw5TightenTime")]
|
||||
public string Screw5TightenTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 6 号螺钉拧紧结果(1 = 合格,0 = 不合格)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw6Result")]
|
||||
public string Screw6Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 6号螺钉扭矩Nm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw6Torque")]
|
||||
public string Screw6Torque { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 6 号螺钉深度mm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw6Depth")]
|
||||
public string Screw6Depth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 6 号螺钉角度°
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw6Angle")]
|
||||
public string Screw6Angle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 6号螺钉拧紧时间秒
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw6TightenTime")]
|
||||
public string Screw6TightenTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 7号螺钉拧紧结果(1 = 合格,0 = 不合格)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw7Result")]
|
||||
public string Screw7Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 7 号螺钉扭矩Nm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw7Torque")]
|
||||
public string Screw7Torque { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 7号螺钉深度mm
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw7Depth")]
|
||||
public string Screw7Depth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 7号螺钉角度°
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw7Angle")]
|
||||
public string Screw7Angle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 7 号螺钉拧紧时间秒
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Screw7TightenTime")]
|
||||
public string Screw7TightenTime { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -89,10 +89,9 @@ namespace RIZO.Admin.WebApi.PLC.Service
|
||||
{ "实际产量", "DB1001.DBD1104" }, // DInt
|
||||
{ "合格数量", "DB1001.DBD1108" }, // DInt
|
||||
{ "失败数量", "DB1001.DBD1112" }, // DInt
|
||||
{ "合装工位查询", "DB1001.DBW2000" }, // Int
|
||||
{ "合装工位查询请求", "DB1001.DBW2000" }, // Int
|
||||
{ "合装结果保存请求", "DB1001.DBW2004" }, // Int
|
||||
{ "拧紧结果保存请求", "DB1001.DBW2006" }, // Int
|
||||
{ "托盘号", "DB1001.DBW2004" }, // Int
|
||||
{ "合装位托盘号", "DB1001.DBW2100" }, // Int
|
||||
{ "拧紧位托盘号", "DB1001.DBW3152" }, // Int
|
||||
// 2号螺钉
|
||||
@ -155,172 +154,6 @@ namespace RIZO.Admin.WebApi.PLC.Service
|
||||
|
||||
#region 核心业务方法
|
||||
|
||||
/// <summary>
|
||||
/// 读取PLC生产数据(优化版:连接池+并发控制+批量读取+异常防护)
|
||||
/// </summary>
|
||||
/// <param name="ip">PLC IP地址</param>
|
||||
/// <param name="rack">机架号</param>
|
||||
/// <param name="slot">槽位号</param>
|
||||
/// <param name="cpuType">PLC型号(默认S7-1500)</param>
|
||||
/// <returns>读取结果(状态+数据+消息)</returns>
|
||||
//public async Task<(bool Success, PlcProductionData Data, string Message)> ReadProductionDataAsync(
|
||||
// string ip,
|
||||
// string plcName,
|
||||
// short rack,
|
||||
// short slot,
|
||||
// CpuType cpuType = CpuType.S71500)
|
||||
//{
|
||||
// // 1. 强化参数校验(源头避免无效请求)
|
||||
// if (string.IsNullOrWhiteSpace(ip))
|
||||
// return (false, null, "PLC IP地址不能为空");
|
||||
// if (rack < 0 || rack > 10) // 工业场景机架号常规范围
|
||||
// return (false, null, $"PLC机架号{rack}无效(有效值0-10)");
|
||||
// if (slot < 0 || slot > 4) // 工业场景槽位号常规范围
|
||||
// return (false, null, $"PLC槽位号{slot}无效(有效值0-4)");
|
||||
|
||||
// Plc plc = null;
|
||||
// bool isConnReused = false; // 标记是否复用连接
|
||||
// var poolKey = $"{ip}_{rack}_{slot}_{cpuType}"; // 连接池唯一标识
|
||||
|
||||
// // 2. 并发控制(防止50台PLC同时访问导致端口/线程耗尽)
|
||||
// await _concurrencySemaphore.WaitAsync();
|
||||
|
||||
// try
|
||||
// {
|
||||
// // 3. 连接池复用(核心优化:避免高频创建/销毁连接)
|
||||
// if (_plcConnPool.TryGetValue(poolKey, out var poolItem) && poolItem.Client.IsConnected)
|
||||
// {
|
||||
// plc = poolItem.Client;
|
||||
// _plcConnPool.TryUpdate(poolKey, (plc, DateTime.Now), poolItem); // 更新最后使用时间
|
||||
// isConnReused = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 初始化新连接(保留你的原始逻辑,增加重试)
|
||||
// plc = CreatePlcClient(cpuType, ip, rack, slot);
|
||||
// // 连接重试(应对临时网络波动)
|
||||
// int retryCount = 2;
|
||||
// bool isConnected = false;
|
||||
// while (retryCount-- > 0 && !isConnected)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// await OpenPlcConnectionAsync(plc);
|
||||
// isConnected = plc.IsConnected;
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// if (retryCount > 0) await Task.Delay(100); // 重试间隔
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!isConnected)
|
||||
// return (false, null, "PLC连接失败(含2次重试)");
|
||||
|
||||
// // 新连接加入池
|
||||
// _plcConnPool.TryAdd(poolKey, (plc, DateTime.Now));
|
||||
// }
|
||||
|
||||
// //先读取查询请求标志,判断是否需要读取生产数据
|
||||
// int iQueryRequest = await ReadPlcIntAsync(plc, _plcIntMap["QueryRequest"]);
|
||||
// if (iQueryRequest != 1)
|
||||
// {
|
||||
// return (false, null, "PLC查询请求标志未设置,跳过生产数据读取");
|
||||
// }
|
||||
// if (plcName == "OP070-1")
|
||||
// {
|
||||
|
||||
|
||||
// }
|
||||
// // 4. 批量并行读取(核心优化:替代串行await,提升效率30%+)
|
||||
// // 4.1 字符串字段批量读取
|
||||
// var stringTasks = new Dictionary<string, Task<string>>
|
||||
// {
|
||||
// { "LineCode", ReadPlcStringAsync(plc, _plcStringMap["LineCode"].Addr, _plcStringMap["LineCode"].Len) },
|
||||
// { "ProductCode", ReadPlcStringAsync(plc, _plcStringMap["ProductCode"].Addr, _plcStringMap["ProductCode"].Len) },
|
||||
// { "ProductName", ReadPlcStringAsync(plc, _plcStringMap["ProductName"].Addr, _plcStringMap["ProductName"].Len) },
|
||||
// { "PartCode", ReadPlcStringAsync(plc, _plcStringMap["PartCode"].Addr, _plcStringMap["PartCode"].Len) },
|
||||
// { "PartName", ReadPlcStringAsync(plc, _plcStringMap["PartName"].Addr, _plcStringMap["PartName"].Len) },
|
||||
// { "ProcessName", ReadPlcStringAsync(plc, _plcStringMap["ProcessName"].Addr, _plcStringMap["ProcessName"].Len) },
|
||||
// { "ParamName", ReadPlcStringAsync(plc, _plcStringMap["ParamName"].Addr, _plcStringMap["ParamName"].Len) },
|
||||
// { "ParamValue", ReadPlcStringAsync(plc, _plcStringMap["ParamValue"].Addr, _plcStringMap["ParamValue"].Len) }
|
||||
// };
|
||||
|
||||
// // 4.2 整数字段批量读取
|
||||
// var intTasks = new Dictionary<string, Task<int>>
|
||||
// {
|
||||
// { "QualificationFlag", ReadPlcIntAsync(plc, _plcIntMap["QualificationFlag"]) },
|
||||
// { "ReworkFlag", ReadPlcIntAsync(plc, _plcIntMap["ReworkFlag"]) },
|
||||
// { "AutoManual", ReadPlcIntAsync(plc, _plcIntMap["AutoManual"]) },
|
||||
// { "RunStatus", ReadPlcIntAsync(plc, _plcIntMap["RunStatus"]) },
|
||||
// { "ProductionCycle", ReadPlcIntAsync(plc, _plcIntMap["ProductionCycle"]) }
|
||||
// };
|
||||
|
||||
// // 等待所有读取完成(并行执行,减少等待时间)
|
||||
// IEnumerable<Task> allTasks = stringTasks.Values.Cast<Task>()
|
||||
// .Concat(intTasks.Values.Cast<Task>());
|
||||
// await Task.WhenAll(allTasks);
|
||||
|
||||
// // 5. 构建数据实体(空值安全处理,单个字段失败不影响整体)
|
||||
// var prodData = new PlcProductionData
|
||||
// {
|
||||
// PlcIp = ip.Trim(),
|
||||
// OccurTime = DateTime.Now,
|
||||
|
||||
// // 字符串字段(空值兜底)
|
||||
// LineCode = await stringTasks["LineCode"] ?? string.Empty,
|
||||
// ProductCode = await stringTasks["ProductCode"] ?? string.Empty,
|
||||
// ProductName = await stringTasks["ProductName"] ?? string.Empty,
|
||||
// PartCode = await stringTasks["PartCode"] ?? string.Empty,
|
||||
// PartName = await stringTasks["PartName"] ?? string.Empty,
|
||||
// ProcessName = await stringTasks["ProcessName"] ?? string.Empty,
|
||||
// ParamName = await stringTasks["ParamName"] ?? string.Empty,
|
||||
// ParamValue = await stringTasks["ParamValue"] ?? string.Empty,
|
||||
|
||||
// // 整数字段(读取失败返回0,不中断流程)
|
||||
// QualificationFlag = (await intTasks["QualificationFlag"]).ToString(),
|
||||
// ReworkFlag = (await intTasks["ReworkFlag"]).ToString(),
|
||||
// AutoManual = await intTasks["AutoManual"],
|
||||
// RunStatus = await intTasks["RunStatus"],
|
||||
// ProductionCycle = await intTasks["ProductionCycle"]
|
||||
// };
|
||||
|
||||
// // 空值兜底(保留你的原始逻辑)
|
||||
// prodData.QualificationFlag ??= "0";
|
||||
// prodData.ReworkFlag ??= "0";
|
||||
// prodData.ProductionCycle ??= 0;
|
||||
|
||||
// // 6. 异步保存数据(非阻塞,提升响应速度)
|
||||
// _ = Task.Run(() => _plcProductionDataService.AddPlcProductionData(prodData))
|
||||
// .ContinueWith(t =>
|
||||
// {
|
||||
// if (t.IsFaulted)
|
||||
// {
|
||||
// // 记录保存失败日志(建议替换为ILogger)
|
||||
// Console.WriteLine($"PLC({ip})数据保存失败:{t.Exception?.InnerException?.Message}");
|
||||
// }
|
||||
// });
|
||||
|
||||
// var successMsg = isConnReused ? "生产数据读取成功(复用连接)" : "生产数据读取成功(新建连接)";
|
||||
// return (true, prodData, successMsg);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// // 精细化异常日志(便于定位具体PLC故障)
|
||||
// Console.WriteLine($"PLC({ip})生产数据读取异常:{ex.Message}\n{ex.StackTrace}");
|
||||
// return (false, null, $"生产数据读取失败:{ex.Message}");
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// // 7. 资源安全释放(核心:复用连接不释放,仅新建连接释放;必须释放并发信号量)
|
||||
// if (!isConnReused)
|
||||
// {
|
||||
// ReleasePlcConnection(plc);
|
||||
// }
|
||||
// _concurrencySemaphore.Release(); // 防止死锁的关键
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 读取PLC生产数据(优化版:连接池+并发控制+OP070-1/OP080专属适配)
|
||||
/// </summary>
|
||||
@ -397,8 +230,19 @@ namespace RIZO.Admin.WebApi.PLC.Service
|
||||
iQueryRequest = await ReadPlcIntAsync(plc, _op070_1IntMap["查询请求"]);
|
||||
iSaveRequest = await ReadPlcIntAsync(plc, _op070_1IntMap["保存请求"]);
|
||||
}
|
||||
// 无效请求直接返回(避免无谓资源消耗)
|
||||
if (iQueryRequest != 1 && iSaveRequest != 1)
|
||||
else if (plcName == "OP080-1")
|
||||
{
|
||||
iQueryRequest = await ReadPlcIntAsync(plc, _op080_1IntMap["合装工位查询请求"]);
|
||||
//考虑一条数据更新两次,还是生成两条数据
|
||||
int iSaveRequest1 = await ReadPlcIntAsync(plc, _op080_1IntMap["合装结果保存请求"]);
|
||||
int iSaveRequest2 = await ReadPlcIntAsync(plc, _op080_1IntMap["拧紧结果保存请求"]);
|
||||
if (iSaveRequest1 == 1 || iSaveRequest2 == 1)
|
||||
{
|
||||
iSaveRequest = 1;
|
||||
}
|
||||
|
||||
} // 无效请求直接返回(避免无谓资源消耗)
|
||||
if (iQueryRequest != 1 && iSaveRequest != 1)
|
||||
{
|
||||
return (false, null, $"");
|
||||
}
|
||||
@ -415,9 +259,9 @@ namespace RIZO.Admin.WebApi.PLC.Service
|
||||
{
|
||||
prodData = await ReadOP070_1DataAsync(plc, ip, plcName);
|
||||
}
|
||||
else if (plcName == "OP080")
|
||||
else if (plcName == "OP080-1" || plcName == "OP080-2")
|
||||
{
|
||||
//prodData = await ReadOP080DataAsync(plc, ip);
|
||||
prodData = await ReadOP080_1DataAsync(plc, ip, plcName);
|
||||
}
|
||||
|
||||
// 6. 统一空值兜底(避免空引用)
|
||||
@ -462,6 +306,11 @@ namespace RIZO.Admin.WebApi.PLC.Service
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<PlcProductionData?> ReadOP080_1DataAsync(Plc plc, string ip, string plcName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#region 工位专属读取方法
|
||||
/// <summary>
|
||||
/// OP070-1数据读取
|
||||
@ -548,8 +397,8 @@ namespace RIZO.Admin.WebApi.PLC.Service
|
||||
SN2 = sn2 ?? string.Empty,
|
||||
QualificationFlag = qualificationFlag,
|
||||
ReworkFlag = reworkFlag,
|
||||
AutoManual = machineModel,
|
||||
RunStatus = runStatus,
|
||||
Automanual = machineModel,
|
||||
Runstatus = runStatus,
|
||||
OnlineStatus = onlineStatusDesc,
|
||||
//ByPass = byPassDesc,
|
||||
ProduceModel = produceModelDesc,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user