<add>[important]添加拣选站台按钮按下上报功能
This commit is contained in:
parent
9ea2702e92
commit
f384489dd0
82
WcsMain/Business/CirculationTask/Convey/PickStandButton.cs
Normal file
82
WcsMain/Business/CirculationTask/Convey/PickStandButton.cs
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
using CirculateTool.Attribute;
|
||||
using WcsMain.ApiClient.DataEntity.WmsEntity;
|
||||
using WcsMain.Common;
|
||||
using WcsMain.DataBase.Dao;
|
||||
using WcsMain.DataBase.TableEntity;
|
||||
using WcsMain.Enum.Convey;
|
||||
using WcsMain.EquipOperation.Convey;
|
||||
using WcsMain.ExtendMethod;
|
||||
using WcsMain.Plugins;
|
||||
|
||||
namespace WcsMain.Business.CirculationTask.Convey;
|
||||
|
||||
/// <summary>
|
||||
/// 拣选站台按钮
|
||||
/// </summary>
|
||||
[Circulation]
|
||||
public class PickStandButton(AppConveyStandDao conveyStandDao, ConveyOperation conveyOperation, WmsWebApiPost wmsWebApiPost)
|
||||
{
|
||||
|
||||
private static List<AppConveyStand>? _pickStands; // 拣选站台
|
||||
|
||||
/// <summary>
|
||||
/// 当拣选站站台按钮按下时上传 wms
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Circulation("拣选站按钮按下上报", 500)]
|
||||
public bool UploadInfo()
|
||||
{
|
||||
if (_pickStands == default)
|
||||
{
|
||||
_pickStands = conveyStandDao.Query(new AppConveyStand() { StandStatus = 1, StandType = (int)ConveyStandTypeEnum.pick });
|
||||
return true;
|
||||
}
|
||||
if (_pickStands.Count < 1)
|
||||
{
|
||||
ConsoleLog.Warning($"【提示】无卡特拣选站台信息,监控已经停止");
|
||||
return false;
|
||||
}
|
||||
List<Task> tasks = [];
|
||||
foreach (var pickStand in _pickStands)
|
||||
{
|
||||
Thread.Sleep(20);
|
||||
Task task = new(() =>
|
||||
{
|
||||
int pickButtonStatus = conveyOperation.GetAllowPickStandGo(pickStand.StandId!);
|
||||
if (pickButtonStatus != 1) return;
|
||||
ConsoleLog.Info($"【提示】拣选站:{pickStand.StandId} 按钮已经按下");
|
||||
|
||||
// 发送wms按钮按下
|
||||
UploadPickStandRequest request = new UploadPickStandRequest()
|
||||
{
|
||||
PickStand = pickStand.StandId,
|
||||
VehicleNo = "",
|
||||
Remark = "按钮按下上报"
|
||||
};
|
||||
var responseEntity = wmsWebApiPost.HttpPost<UploadPickStandRequest, WmsResponse>(request,
|
||||
CommonData.AppApiBaseInfos.GetAddress("UploadPickStandButtonMethod") ?? "", 5000);
|
||||
if (!responseEntity.IsSend) return; // 发送失败不处理,下一次循环在发送
|
||||
// 只要发送成功则不再发送
|
||||
ConsoleLog.Info( $"拣选站:{pickStand.StandId} 按钮已经按下上报成功,WMS返回:{responseEntity.ResponseMsg}");
|
||||
var result = responseEntity.ResponseEntity;
|
||||
if (result is { Code: 0 })
|
||||
{
|
||||
conveyOperation.AllowPickStandGo(pickStand.StandId!, 2);
|
||||
ConsoleLog.Success($"{pickStand.StandId}按钮按下,放行成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
conveyOperation.AllowPickStandGo(pickStand.StandId!, 0);
|
||||
ConsoleLog.Error($"【异常】{pickStand.StandId}按钮按下,wms返回异常:{result?.Message}");
|
||||
}
|
||||
});
|
||||
task.Start();
|
||||
tasks.Add(task);
|
||||
}
|
||||
Task.WaitAll([.. tasks]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -191,6 +191,32 @@ public class ConveyOperation
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 读取拣选站台释放的信号
|
||||
/// </summary>
|
||||
/// <param name="pickStandId"></param>
|
||||
/// <returns></returns>
|
||||
public int GetAllowPickStandGo(string pickStandId)
|
||||
{
|
||||
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return 0;
|
||||
var readResult = CommonTool.Siemens.ReadInt16WithName($"拣选确认按钮{pickStandId}");
|
||||
if (!readResult.Success) return 0;// 读取失败
|
||||
return readResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通知 plc 可以释放站台
|
||||
/// </summary>
|
||||
/// <param name="pickStandId"></param>
|
||||
/// <param name="router"></param>
|
||||
/// <returns></returns>
|
||||
public string AllowPickStandGo(string pickStandId, short router)
|
||||
{
|
||||
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return "PLC尚未连接。";
|
||||
var (writeResult, _) = CommonTool.Siemens.WritePlcWhithName($"拣选站台释放{pickStandId}", router);
|
||||
if (!writeResult.Success) return writeResult.Message ?? "写入失败"; // 读取失败
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"DBMssqlLocal": "Data Source=192.168.142.131;Initial Catalog=wcs_stacker;User Id=sa;Password=Sa123;",
|
||||
|
||||
"ApplicationConfig": {
|
||||
"ApiOnly": true,
|
||||
"ApiOnly": false,
|
||||
"Language": "zh-CN"
|
||||
},
|
||||
"UseUrls": [ "http://*:890" ]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user