<add>[important]添加料箱到达站台上报
This commit is contained in:
parent
5c350543e2
commit
8db348817b
102
WcsMain/Business/CirculationTask/Convey/UploadBoxArrive.cs
Normal file
102
WcsMain/Business/CirculationTask/Convey/UploadBoxArrive.cs
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
[Circulation]
|
||||||
|
public class UploadBoxArrive(AppConveyStandDao conveyStandDao, ConveyOperation conveyOperation, WmsWebApiPost wmsWebApiPost, AppConveyTaskDao conveyTaskDao)
|
||||||
|
{
|
||||||
|
private static List<AppConveyStand>? _pickStands; // 拣选站台
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拣选台上报料箱
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Circulation("拣选台上报料箱")]
|
||||||
|
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 = new();
|
||||||
|
foreach (AppConveyStand stand in _pickStands)
|
||||||
|
{
|
||||||
|
Thread.Sleep(20);
|
||||||
|
Task task = new(() =>
|
||||||
|
{
|
||||||
|
string code = conveyOperation.ReadStandCode(stand.Area!);
|
||||||
|
code = Regex.Replace(code, "\\W", "");
|
||||||
|
if (string.IsNullOrEmpty(code))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ConsoleLog.Info($"【提示】料箱:{code} 已经到达拣选站台:{stand.Area}");
|
||||||
|
conveyOperation.ClearStandCodeStatus(stand.Area!);
|
||||||
|
|
||||||
|
// 查询 条码 对应的任务
|
||||||
|
List<AppConveyTask>? pickTasks = conveyTaskDao.Query(new AppConveyTask()
|
||||||
|
{
|
||||||
|
VehicleNo = code,
|
||||||
|
TaskType = (int)ConveyTaskTypeEnum.pick,
|
||||||
|
Location = stand.Area
|
||||||
|
});
|
||||||
|
if (pickTasks == default || pickTasks.Count < 1)
|
||||||
|
{
|
||||||
|
ConsoleLog.Error($"【异常】拣选站台{stand.Area} 料箱:{code} 找不到对应任务");
|
||||||
|
conveyOperation.ClearStandCodeStatus(stand.Area!);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var pickTask = pickTasks[0]; // 拣选任务
|
||||||
|
// 更新表内拣选时间和状态
|
||||||
|
conveyTaskDao.Update(new AppConveyTask()
|
||||||
|
{
|
||||||
|
TaskId = pickTask.TaskId,
|
||||||
|
TaskStatus = (int)ConveyTaskStatusEnum.arrive,
|
||||||
|
CompleteTime = DateTime.Now,
|
||||||
|
Remark = "PLC上报料箱到达"
|
||||||
|
});
|
||||||
|
// 发送wms料箱到达
|
||||||
|
UploadPickStandRequest request = new UploadPickStandRequest()
|
||||||
|
{
|
||||||
|
PickStand = stand.Area,
|
||||||
|
VehicleNo = pickTask.VehicleNo,
|
||||||
|
Remark = ""
|
||||||
|
};
|
||||||
|
|
||||||
|
var responseEntity = wmsWebApiPost.HttpPost<UploadPickStandRequest, WmsResponse>(request,
|
||||||
|
CommonData.AppApiBaseInfos.GetAddress("UploadBoxArrive") ?? "", 5000);
|
||||||
|
if (responseEntity.IsSend) // 发送失败不处理,下一次循环在发送
|
||||||
|
{
|
||||||
|
// 只要发送成功则不再发送
|
||||||
|
ConsoleLog.Info(
|
||||||
|
$"拣选站台{stand.Area} 获得对应料箱:{pickTask.VehicleNo} 上报成功,WMS返回:{responseEntity.ResponseMsg}");
|
||||||
|
var result = responseEntity.ResponseEntity;
|
||||||
|
conveyOperation.ClearStandCodeStatus(stand.Area!);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
task.Start();
|
||||||
|
tasks.Add(task);
|
||||||
|
}
|
||||||
|
Task.WaitAll(tasks.ToArray());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -113,6 +113,44 @@ public class ConveyOperation
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取站台扫码点信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="scanId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ReadStandCode(string? standId)
|
||||||
|
{
|
||||||
|
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return string.Empty;
|
||||||
|
var readResult = CommonTool.Siemens.ReadByteWithName($"站台条码读取{standId}", 22);
|
||||||
|
if (!readResult.Success || readResult.Value == default) return string.Empty;// 读取失败
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var readData = readResult.Value;
|
||||||
|
short status = Convert.ToInt16(CommonTool.Siemens.Trans<short>(readData, 0)); // PLC 返回任务状态
|
||||||
|
string code = Regex.Replace(Encoding.ASCII.GetString(readData, 2, 20), "\\W", "");
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_ = ex;
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清除站台扫码状态
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="scanId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ClearStandCodeStatus(string? standId)
|
||||||
|
{
|
||||||
|
if (!CommonData.IsConnectPlc || CommonTool.Siemens == default) return "PLC尚未连接。";
|
||||||
|
var (writeResult, _) = CommonTool.Siemens.WritePlcWhithName($"站台条码读取{standId}", (short)0);
|
||||||
|
if (!writeResult.Success) return writeResult.Message ?? "写入失败";
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 写入箱式线任务
|
/// 写入箱式线任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user