diff --git a/WcsMain/ApiServe/Controllers/Dto/WcsDto/StackerConvey/StackerConveyStatusResponse.cs b/WcsMain/ApiServe/Controllers/Dto/WcsDto/StackerConvey/StackerConveyStatusResponse.cs new file mode 100644 index 0000000..a665467 --- /dev/null +++ b/WcsMain/ApiServe/Controllers/Dto/WcsDto/StackerConvey/StackerConveyStatusResponse.cs @@ -0,0 +1,80 @@ +using System.Text.Json.Serialization; + +namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.StackerConvey; + +public class StackerConveyStatusResponse +{ + /// + /// WCS 点位 + /// + [JsonPropertyName("wcsLocation")] + public string? WcsLocation { get; set; } + + /// + /// WMS 点位 + /// + [JsonPropertyName("wmsLocation")] + public string? WmsLocation { get; set; } + + /// + /// 点位名称 + /// + [JsonPropertyName("locationName")] + public string? LocationName { get; set; } + + /// + /// plc 的位置 + /// + [JsonPropertyName("plcLocation")] + public string? PlcLocation { get; set; } + + /// + /// 区域 + /// + [JsonPropertyName("area")] + public string? Area { get; set; } + + /// + /// 点位类型 + /// + [JsonPropertyName("locationType")] + public int? LocationType { get; set; } + + /// + /// 点位状态 + /// + [JsonPropertyName("locationStatus")] + public int? LocationStatus { get; set; } + + /// + /// 写入方式 + /// + [JsonPropertyName("writeType")] + public int? WriteType { get; set; } + + /// + /// 备注信息 + /// + [JsonPropertyName("remark")] + public string? Remark { get; set; } + + + /// + /// 查询结果 + /// + [JsonPropertyName("msg")] + public string? Message { get; set; } = "-"; + + /// + /// 条码 + /// + [JsonPropertyName("code")] + public string? Code { get; set; } + + /// + /// 动作允许 + /// + [JsonPropertyName("allowAction")] + public bool? AllowAction { get; set; } + +} diff --git a/WcsMain/ApiServe/Controllers/WcsController/StackerConveyController.cs b/WcsMain/ApiServe/Controllers/WcsController/StackerConveyController.cs index aec3402..58f00db 100644 --- a/WcsMain/ApiServe/Controllers/WcsController/StackerConveyController.cs +++ b/WcsMain/ApiServe/Controllers/WcsController/StackerConveyController.cs @@ -5,6 +5,7 @@ using WcsMain.ApiServe.ControllerFilter; using WcsMain.ApiServe.Service.WcsService; using WcsMain.ApiServe.Controllers.Dto; using WcsMain.DataBase.TableEntity; +using WcsMain.ApiServe.Controllers.Dto.WcsDto.StackerConvey; namespace WcsMain.ApiServe.Controllers.WcsController; @@ -24,7 +25,11 @@ public class StackerConveyController(StackerConveyService stackerConveyService) [HttpGet("queryStackerConveyInfo")] public WcsApiResponse>? QueryStackerConveyInfo() => stackerConveyService.QueryStackerConveyInfo(); - - + /// + /// 查询所有库前输送线状态信息 + /// + /// + [HttpGet("queryStackerConveyStatus")] + public WcsApiResponse>? QueryStackerConveyStatus() => stackerConveyService.QueryStackerConveyStatus(); } diff --git a/WcsMain/ApiServe/Service/WcsService/StackerConveyService.cs b/WcsMain/ApiServe/Service/WcsService/StackerConveyService.cs index df9e898..24117dd 100644 --- a/WcsMain/ApiServe/Service/WcsService/StackerConveyService.cs +++ b/WcsMain/ApiServe/Service/WcsService/StackerConveyService.cs @@ -1,7 +1,12 @@ -using WcsMain.ApiServe.Controllers.Dto; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using WcsMain.ApiServe.Controllers.Dto; +using WcsMain.ApiServe.Controllers.Dto.WcsDto.StackerConvey; using WcsMain.ApiServe.Factory; using WcsMain.DataBase.Dao; using WcsMain.DataBase.TableEntity; +using WcsMain.EquipOperation.Convey; +using WcsMain.EquipOperation.StackerConvey; +using WcsMain.Plugins; using WcsMain.WcsAttribute.AutoFacAttribute; namespace WcsMain.ApiServe.Service.WcsService; @@ -10,7 +15,7 @@ namespace WcsMain.ApiServe.Service.WcsService; /// 库前输送线的 Service /// [Service] -public class StackerConveyService(AppStackerConveyDao stackerConveyDao) +public class StackerConveyService(AppStackerConveyDao stackerConveyDao, ConveyOperation conveyOperation) { /// @@ -22,4 +27,44 @@ public class StackerConveyService(AppStackerConveyDao stackerConveyDao) List? stackerConveys = stackerConveyDao.Query(); return stackerConveys == default ? WcsApiResponseFactory.DataBaseErr>() : WcsApiResponseFactory.Success(stackerConveys); } + + /// + /// 查询所有的库前输送线状态信息 + /// + /// + public WcsApiResponse>? QueryStackerConveyStatus() + { + List? stackerConveys = stackerConveyDao.Query(); + if(stackerConveys == default) return WcsApiResponseFactory.DataBaseErr>(); + if(stackerConveys.Count == 0) return WcsApiResponseFactory.Fail>(default, "未找到库前输送机数据,请检查基础资料"); + List responseData = []; + foreach (var stackerConvey in stackerConveys) + { + StackerConveyStatusResponse stackerConveyStatusResponse = ObjectCopy.CopyProperties(stackerConvey); + stackerConveyStatusResponse.Message = "查询成功"; + // 读取条码 + (string? errText, string? code) = conveyOperation.ReadConveyCode(stackerConvey.WcsLocation); + if(!string.IsNullOrEmpty(errText)) + { + stackerConveyStatusResponse.Message = errText; + responseData.Add(stackerConveyStatusResponse); + continue; + } + stackerConveyStatusResponse.Code = code; + + // 读取允许取放货状态 + // ---- 取货站台 + if(stackerConvey.LocationType == 1) + { + stackerConveyStatusResponse.AllowAction = conveyOperation.AllowGetVehicle(stackerConvey.WcsLocation![..1]); + } + if(stackerConvey.LocationType == 2) + { + stackerConveyStatusResponse.AllowAction = conveyOperation.AllowSetVehicle(stackerConvey.WcsLocation![..1]); + } + responseData.Add(stackerConveyStatusResponse); + } + return WcsApiResponseFactory.Success(responseData); + } + } diff --git a/WcsMain/Business/CirculationTask/Stacker/ExeTaskDoubleFork.cs b/WcsMain/Business/CirculationTask/Stacker/ExeTaskDoubleFork.cs index 743584a..6725e90 100644 --- a/WcsMain/Business/CirculationTask/Stacker/ExeTaskDoubleFork.cs +++ b/WcsMain/Business/CirculationTask/Stacker/ExeTaskDoubleFork.cs @@ -74,10 +74,10 @@ public class ExeTaskDoubleFork( { if (stackerId == default) return false; /* 检查入库站台是否允许取货 */ - bool allowGetGoods = conveyOperation.AllGetVehicle(stackerId.ToString()); + bool allowGetGoods = conveyOperation.AllowGetVehicle(stackerId.ToString()); if(!allowGetGoods) return false; // 入库站台不允许取货 /* 读取入库站台的条码 */ - var codes = conveyOperation.ReadConveyCode(stackerId.ToString()); + var codes = conveyOperation.ReadAreaConveyCode(stackerId.ToString()); if(codes == default || codes.Count != 2) return false; /* 构造任务数据 */ bool isWriteTask = false; // 指示是否写入任务 @@ -92,7 +92,7 @@ public class ExeTaskDoubleFork( if (code == "NoRead") // 检查条码是否为 NoRead { /* 检查卸货站台是否允许卸货 */ - bool allowSetGoods = conveyOperation.AllSetVehicle(stackerId.ToString()); + bool allowSetGoods = conveyOperation.AllowSetVehicle(stackerId.ToString()); if (!allowSetGoods) continue; // 出库站台不允许取货 /* 生成一个直接卸货出去的任务 */ int? plcId = dataBaseData.GetNewPlcTaskId(); @@ -119,7 +119,7 @@ public class ExeTaskDoubleFork( if(wcsTasks.Count < 1) // 没有任务 { /* 检查卸货站台是否允许卸货 */ - bool allowSetGoods = conveyOperation.AllSetVehicle(stackerId.ToString()); + bool allowSetGoods = conveyOperation.AllowSetVehicle(stackerId.ToString()); if (!allowSetGoods) continue; // 出库站台不允许取货 /* 生成一个直接卸货出去的任务 */ ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code} 没有找到对应任务"); @@ -144,7 +144,7 @@ public class ExeTaskDoubleFork( if(destinationLocationInfo == default) // 任务终点错误,理论上此处不应该出现异常 { /* 检查卸货站台是否允许卸货 */ - bool allowSetGoods = conveyOperation.AllSetVehicle(stackerId.ToString()); + bool allowSetGoods = conveyOperation.AllowSetVehicle(stackerId.ToString()); if (!allowSetGoods) continue; // 出库站台不允许取货 /* 生成一个直接卸货出去的任务 */ ConsoleLog.Warning($"【警告】{stackerId} 号堆垛机,入库位置:{i + 1} 条码:{code} 无法识别的入库库位"); @@ -200,7 +200,7 @@ public class ExeTaskDoubleFork( { if (stackerId == default) return false; /* 检查出库站台是否可以卸货 */ - bool allowSetGoods = conveyOperation.AllSetVehicle(stackerId.ToString()); + bool allowSetGoods = conveyOperation.AllowSetVehicle(stackerId.ToString()); if (!allowSetGoods) return false; // 出库站台不允许取货 var wcsTasks = wcsTaskDao.SelectOutTaskWithStacker((int)stackerId!); if (wcsTasks == default) diff --git a/WcsMain/EquipOperation/Convey/ConveyOperation.cs b/WcsMain/EquipOperation/Convey/ConveyOperation.cs index dfc3db0..e968620 100644 --- a/WcsMain/EquipOperation/Convey/ConveyOperation.cs +++ b/WcsMain/EquipOperation/Convey/ConveyOperation.cs @@ -28,7 +28,7 @@ public class ConveyOperation /// /// 要取货的点位 /// - public bool AllGetVehicle(string? point) + public bool AllowGetVehicle(string? point) { if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return false; var readResult = CommonTool.Siemens.ReadInt16WithName($"箱式线允许取货{point}"); @@ -40,7 +40,7 @@ public class ConveyOperation /// /// 要取货的点位 /// - public bool AllSetVehicle(string? point) + public bool AllowSetVehicle(string? point) { if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return false; var readResult = CommonTool.Siemens.ReadInt16WithName($"箱式线允许卸货{point}"); @@ -52,7 +52,7 @@ public class ConveyOperation /// /// /// - public List? ReadConveyCode(string? point) + public List? ReadAreaConveyCode(string? point) { if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return default; var readResult1 = CommonTool.Siemens.ReadStringWithName($"箱式线入库载具号{point}-1", 20, Encoding.ASCII); @@ -62,6 +62,20 @@ public class ConveyOperation return [Regex.Replace(readResult1.Value ?? "", "\\W", ""), Regex.Replace(readResult2.Value ?? "", "\\W", "")]; } + /// + /// 读取箱号 + /// + /// + /// + public (string? errText, string? code) ReadConveyCode(string? point) + { + if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return ("设备离线", default); + var readResult1 = CommonTool.Siemens.ReadStringWithName($"箱式线入库载具号{point}", 20, Encoding.ASCII); + if (!readResult1.Success!) return (readResult1.Message, default); + // 返回读取到的任务号 + return (default, Regex .Replace(readResult1.Value ?? "", "\\W", "")); + } + /// /// 读取扫码点信息 diff --git a/WcsMain/Plugins/ObjectCopy.cs b/WcsMain/Plugins/ObjectCopy.cs index ee221da..555e166 100644 --- a/WcsMain/Plugins/ObjectCopy.cs +++ b/WcsMain/Plugins/ObjectCopy.cs @@ -4,6 +4,9 @@ /// /// object 拷贝 /// +/// +/// 作者:icewint(菻蔃) +/// public class ObjectCopy {