2024-10-07 09:51:55 +08:00
|
|
|
|
using CirculateTool.Attribute;
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
using WcsMain.ApiClient.DataEntity.WmsEntity;
|
|
|
|
|
|
using WcsMain.Common;
|
|
|
|
|
|
using WcsMain.DataBase.Dao;
|
|
|
|
|
|
using WcsMain.DataBase.TableEntity;
|
|
|
|
|
|
using WcsMain.DataService;
|
|
|
|
|
|
using WcsMain.Enum.Convey;
|
|
|
|
|
|
using WcsMain.EquipOperation.Convey;
|
|
|
|
|
|
using WcsMain.ExtendMethod;
|
|
|
|
|
|
using WcsMain.Plugins;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WcsMain.Business.CirculationTask.Convey;
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-07 09:59:48 +08:00
|
|
|
|
//[Circulation]
|
2024-10-07 09:51:55 +08:00
|
|
|
|
public class UploadBoxArrive(AppConveyStandDao conveyStandDao, ConveyOperation conveyOperation, WmsWebApiPost wmsWebApiPost, AppConveyTaskDao conveyTaskDao, AppElTagTaskDao elTagTaskDao)
|
|
|
|
|
|
{
|
|
|
|
|
|
private static List<AppConveyStand>? _pickStands; // 拣选站台
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 拣选台上报料箱
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[Circulation("拣选台上报料箱", 300)]
|
|
|
|
|
|
public bool UploadInfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_pickStands == default)
|
|
|
|
|
|
{
|
|
|
|
|
|
_pickStands = conveyStandDao.Query(new AppConveyStand() { StandStatus = 1, StandType = (int)ConveyStandTypeEnum.pick });
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_pickStands.Count < 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
ConsoleLog.Info($"【提示】无拣选站台信息,监控已经停止");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
List<Task> tasks = [];
|
|
|
|
|
|
foreach (AppConveyStand stand in _pickStands)
|
|
|
|
|
|
{
|
|
|
|
|
|
Task task = new(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
string code = conveyOperation.ReadStandCode(stand.StandId!);
|
|
|
|
|
|
code = Regex.Replace(code, "\\W", "");
|
|
|
|
|
|
if (string.IsNullOrEmpty(code)) return;
|
|
|
|
|
|
elTagTaskDao.ClearNotCompleteTaskWithStand(stand.StandId); // 清理之前未完成的电子标签任务
|
|
|
|
|
|
ConsoleLog.Info($"【提示】料箱:{code} 已经到达拣选站台:{stand.StandId}");
|
|
|
|
|
|
conveyOperation.ClearStandCodeStatus(stand.StandId!);
|
|
|
|
|
|
|
|
|
|
|
|
// 查询 条码 对应的任务
|
|
|
|
|
|
List<AppConveyTask>? pickTasks = conveyTaskDao.Query(new AppConveyTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
VehicleNo = code,
|
|
|
|
|
|
TaskType = (int)ConveyTaskTypeEnum.pick,
|
|
|
|
|
|
Location = stand.StandId,
|
|
|
|
|
|
TaskStatus = (int)ConveyTaskStatusEnum.create
|
|
|
|
|
|
});
|
|
|
|
|
|
if (pickTasks == default || pickTasks.Count < 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
ConsoleLog.Error($"【异常】拣选站台{stand.StandId} 料箱:{code} 找不到对应任务");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var pickTask = pickTasks[0]; // 拣选任务
|
|
|
|
|
|
conveyTaskDao.Update(new AppConveyTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
TaskId = pickTask.TaskId,
|
|
|
|
|
|
TaskStatus = (int)ConveyTaskStatusEnum.arrive,
|
|
|
|
|
|
ArriveLocation = stand.StandId,
|
|
|
|
|
|
CompleteTime = DateTime.Now,
|
|
|
|
|
|
Remark = "PLC上报料箱到达"
|
|
|
|
|
|
}); // 更新表内拣选时间和状态
|
|
|
|
|
|
}
|
|
|
|
|
|
// 发送wms料箱到达
|
|
|
|
|
|
UploadPickStandRequest request = new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Location = stand.StandId,
|
|
|
|
|
|
VehicleNo = code,
|
|
|
|
|
|
Remark = $"料箱:{code} 已经到达站台:{stand.StandId}"
|
|
|
|
|
|
};
|
|
|
|
|
|
var responseEntity = wmsWebApiPost.HttpPost<UploadPickStandRequest, WmsResponse>(request, CommonData.AppApiBaseInfos.GetAddress("UploadBoxArrive") ?? "", 2000);
|
|
|
|
|
|
if (responseEntity.IsSend) // 发送失败不处理,下一次循环在发送
|
|
|
|
|
|
{
|
|
|
|
|
|
// 只要发送成功则不再发送
|
|
|
|
|
|
ConsoleLog.Info($"拣选站台{stand.Area} 获得对应料箱:{code} 上报成功,WMS返回:{responseEntity.ResponseMsg}");
|
|
|
|
|
|
conveyOperation.ClearStandCodeStatus(stand.Area!);
|
|
|
|
|
|
//var result = responseEntity.ResponseEntity;
|
|
|
|
|
|
//if (result != null && result.Code == 0) // 上报成功
|
|
|
|
|
|
//{
|
|
|
|
|
|
// conveyOperation.ClearStandCodeStatus(stand.Area!);
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
task.Start();
|
|
|
|
|
|
tasks.Add(task);
|
|
|
|
|
|
}
|
|
|
|
|
|
Task.WaitAll([.. tasks]);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|