|
|
|
@ -94,20 +94,24 @@ namespace Aucma.Scada.Business
|
|
|
|
|
_baseSpaceDetailService = registerServices.GetService<IBaseSpaceDetailService>();
|
|
|
|
|
_baseBomInfoService = registerServices.GetService<IBaseBomInfoService>();
|
|
|
|
|
_recordInStore = registerServices.GetService<IRecordInStoreService>();
|
|
|
|
|
taskHandle.InStoreFinsihEvent += TaskFeedback;
|
|
|
|
|
|
|
|
|
|
taskHandle.InStoreFinsihEvent += InStoreFinish;
|
|
|
|
|
taskHandle.InStoreAnswerEvent += InStoreAnswer;
|
|
|
|
|
|
|
|
|
|
grabImage.RefreshMaterialCodeStrEvent += InStore;
|
|
|
|
|
grabImage.RefreshLogMessageEvent += PrintLogInfoMessage;
|
|
|
|
|
|
|
|
|
|
StartPassDown();
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(6000);
|
|
|
|
|
for (int i = 1; i < 12; i++)
|
|
|
|
|
for (int i = 1; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
//InStore(appConfig.shellStoreCode, "B2360000078110600" + i.ToString().PadLeft(2, '0'));
|
|
|
|
|
//Thread.Sleep(1000*60*1);
|
|
|
|
|
//InStore(appConfig.linerStoreCode, "L2360000078110600" + i.ToString().PadLeft(2, '0'));
|
|
|
|
|
//InStore(appConfig.shellStoreCode, "B23600000781110800" + i.ToString().PadLeft(2, '0'));
|
|
|
|
|
//Thread.Sleep(1000*60*1);
|
|
|
|
|
InStore(appConfig.linerStoreCode, "L23600000781110800" + i.ToString().PadLeft(2, '0'));
|
|
|
|
|
Thread.Sleep(1000 * 30);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -195,26 +199,28 @@ namespace Aucma.Scada.Business
|
|
|
|
|
|
|
|
|
|
private SemaphoreSlim linerSemaphore = new SemaphoreSlim(0);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务下发
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void StartPassDown()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
PassDownShellTask();
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
PassDownLinerTask();
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -227,28 +233,26 @@ namespace Aucma.Scada.Business
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void PassDownShellTask()
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo taskInfo = GetAwaitSendTask(appConfig.shellStoreCode);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo taskInfo = taskInfo = _taskInfoService.GetTaskInfoByStoreCode(appConfig.shellStoreCode, appConfig.instoreTaskType);
|
|
|
|
|
if (taskInfo != null)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"下发箱壳入库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}");
|
|
|
|
|
//taskHandle.SendShellTask_InStore(taskInfo);
|
|
|
|
|
|
|
|
|
|
if (taskHandle.SendShellTask_InStore(taskInfo))
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"箱壳入库任务:{taskInfo.taskCode};下发成功,等待PLC执行反馈");
|
|
|
|
|
taskInfo.taskStatus = 2;
|
|
|
|
|
|
|
|
|
|
_taskInfoService.UpdateTaskInfo(taskInfo);
|
|
|
|
|
|
|
|
|
|
RefreshInStoreTaskEvent?.Invoke(taskInfo);
|
|
|
|
|
shellSemaphore.Wait(); //一直堵塞直到信号量释放
|
|
|
|
|
|
|
|
|
|
taskHandle.WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
|
|
|
|
|
PrintLogInfoMessage($"箱壳入库任务:{taskInfo.taskCode};开始执行");
|
|
|
|
|
|
|
|
|
|
shellSemaphore.Wait(); //一直堵塞直到信号量释放
|
|
|
|
|
taskInfo.taskStatus = 2;
|
|
|
|
|
|
|
|
|
|
PrintLogInfoMessage($"箱壳入库任务:{taskInfo.taskCode};执行完成");
|
|
|
|
|
_taskInfoService.UpdateTaskInfo(taskInfo);
|
|
|
|
|
|
|
|
|
|
RefreshInStoreTaskEvent?.Invoke(taskInfo,true);
|
|
|
|
|
RefreshInStoreTaskEvent?.Invoke(taskInfo);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -260,7 +264,10 @@ namespace Aucma.Scada.Business
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("未获取到需要下发的箱壳入库任务");
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("依次获取箱壳任务队列进行下发逻辑异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -268,7 +275,9 @@ namespace Aucma.Scada.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void PassDownLinerTask()
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo taskInfo = GetAwaitSendTask(appConfig.linerStoreCode);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo taskInfo = taskInfo = _taskInfoService.GetTaskInfoByStoreCode(appConfig.linerStoreCode, appConfig.instoreTaskType);
|
|
|
|
|
if (taskInfo != null)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"下发内胆入库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}");
|
|
|
|
@ -276,19 +285,16 @@ namespace Aucma.Scada.Business
|
|
|
|
|
if (taskHandle.SendLinerTask_InStore(taskInfo))
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode};下发成功,等待PLC执行反馈");
|
|
|
|
|
taskInfo.taskStatus = 2;
|
|
|
|
|
|
|
|
|
|
_taskInfoService.UpdateTaskInfo(taskInfo);
|
|
|
|
|
|
|
|
|
|
RefreshInStoreTaskEvent?.Invoke(taskInfo);
|
|
|
|
|
linerSemaphore.Wait(); //一直堵塞直到信号量释放
|
|
|
|
|
|
|
|
|
|
taskHandle.WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false);
|
|
|
|
|
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode};开始执行");
|
|
|
|
|
|
|
|
|
|
linerSemaphore.Wait(); //一直堵塞直到信号量释放
|
|
|
|
|
taskInfo.taskStatus = 2;
|
|
|
|
|
|
|
|
|
|
PrintLogInfoMessage($"内胆入库任务:{taskInfo.taskCode};执行完成");
|
|
|
|
|
_taskInfoService.UpdateTaskInfo(taskInfo);
|
|
|
|
|
|
|
|
|
|
RefreshInStoreTaskEvent?.Invoke(taskInfo,true);
|
|
|
|
|
RefreshInStoreTaskEvent?.Invoke(taskInfo);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -298,91 +304,70 @@ namespace Aucma.Scada.Business
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("未获取到需要下发的内胆入库任务");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("依次获取内胆任务队列进行下发逻辑异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取待执行的入库任务
|
|
|
|
|
/// 入库应答,PLC收到入库任务后进行应答
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private RealTaskInfo GetAwaitSendTask(string storeCode)
|
|
|
|
|
/// <param name="taskCode"></param>
|
|
|
|
|
private void InStoreAnswer(string storeCode, string taskCode)
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo taskInfo = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
if (storeCode == appConfig.shellStoreCode)
|
|
|
|
|
{
|
|
|
|
|
taskInfo = _taskInfoService.GetTaskInfoByStoreCode(storeCode, 1);
|
|
|
|
|
PrintLogInfoMessage("箱壳应答成功,自动释放信号量,进行下发新任务");
|
|
|
|
|
|
|
|
|
|
shellSemaphore.Release();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("获取待执行的入库任务异常", ex);
|
|
|
|
|
}
|
|
|
|
|
PrintLogInfoMessage("内胆应答成功,自动释放信号量,进行下发新任务");
|
|
|
|
|
|
|
|
|
|
return taskInfo;
|
|
|
|
|
linerSemaphore.Release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务反馈(入库完成)
|
|
|
|
|
/// 入库完成
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="taskCode"></param>
|
|
|
|
|
private void TaskFeedback(string storeCode,string taskCode)
|
|
|
|
|
private void InStoreFinish(string storeCode, string taskCode)
|
|
|
|
|
{
|
|
|
|
|
if (storeCode == appConfig.shellStoreCode)
|
|
|
|
|
{
|
|
|
|
|
ShellTaskFeedback(taskCode);
|
|
|
|
|
PrintLogInfoMessage($"箱壳任务:{taskCode};执行完成");
|
|
|
|
|
|
|
|
|
|
InStoreFinishHandle(taskCode, appConfig.shellStoreCode);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LinerTaskFeedback(taskCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 箱壳执行反馈
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void ShellTaskFeedback(string taskCode)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
PrintLogInfoMessage("箱壳执行完成,自动释放信号量");
|
|
|
|
|
|
|
|
|
|
InStoreFinish(taskCode, appConfig.shellStoreCode);
|
|
|
|
|
|
|
|
|
|
shellSemaphore.Release();
|
|
|
|
|
PrintLogInfoMessage($"内胆任务:{taskCode};执行完成");
|
|
|
|
|
|
|
|
|
|
InStoreFinishHandle(taskCode, appConfig.linerStoreCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 内胆执行反馈
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void LinerTaskFeedback(string taskCode)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("内胆执行完成,自动释放信号量");
|
|
|
|
|
|
|
|
|
|
InStoreFinish(taskCode, appConfig.linerStoreCode);
|
|
|
|
|
|
|
|
|
|
linerSemaphore.Release();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 入库完成
|
|
|
|
|
/// 入库完成逻辑处理
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="spaceCode"></param>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
private void InStoreFinish(string taskCode, string storeCode)
|
|
|
|
|
private void InStoreFinishHandle(string taskCode, string storeCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var taskInfo = _taskInfoService.GetTaskInfoByTaskCode(taskCode, storeCode);
|
|
|
|
|
if (taskInfo != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(taskInfo.storeCode, taskInfo.spaceCode);
|
|
|
|
|
|
|
|
|
|
if (spaceInfo != null)
|
|
|
|
@ -431,7 +416,7 @@ namespace Aucma.Scada.Business
|
|
|
|
|
//清除任务信息
|
|
|
|
|
_taskInfoService.DeleteTaskInfo(taskCode, storeCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RefreshInStoreTaskEvent?.Invoke(taskInfo, true);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -439,27 +424,6 @@ namespace Aucma.Scada.Business
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日志输出,界面刷新同时记录文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
private void PrintLogInfoMessage(string message)
|
|
|
|
|
{
|
|
|
|
|
RefreshLogMessageEvent?.Invoke(message);
|
|
|
|
|
logHelper.Info(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异常日志输出
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
/// <param name="ex"></param>
|
|
|
|
|
private void PrintLogErrorMessage(string message, Exception ex = null)
|
|
|
|
|
{
|
|
|
|
|
RefreshLogMessageEvent?.Invoke(message);
|
|
|
|
|
logHelper.Error(message, ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 截取条码
|
|
|
|
|
/// </summary>
|
|
|
|
@ -476,9 +440,13 @@ namespace Aucma.Scada.Business
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取已创建的所有入库任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<RealTaskInfo> GetInStoreTask()
|
|
|
|
|
{
|
|
|
|
|
return _taskInfoService.GetTaskInfosByStoreCode(new string[] { appConfig.shellStoreCode,appConfig.linerStoreCode }, 1);
|
|
|
|
|
return _taskInfoService.GetTaskInfosByStoreCode(new string[] { appConfig.shellStoreCode,appConfig.linerStoreCode }, appConfig.instoreTaskType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -507,6 +475,7 @@ namespace Aucma.Scada.Business
|
|
|
|
|
return _spaceInfoService.GetMaterialStock(appConfig.shellStoreCode, appConfig.linerStoreCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 通过PLC读取货道信息:在库、在途、货道状态
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC读取货道信息(在途数量、在库数量、货道状态)
|
|
|
|
|
/// </summary>
|
|
|
|
@ -536,7 +505,8 @@ namespace Aucma.Scada.Business
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception ex)
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("货道信息读取异常", ex);
|
|
|
|
|
}
|
|
|
|
@ -578,5 +548,29 @@ namespace Aucma.Scada.Business
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 日志输出
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日志输出,界面刷新同时记录文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
private void PrintLogInfoMessage(string message)
|
|
|
|
|
{
|
|
|
|
|
RefreshLogMessageEvent?.Invoke(message);
|
|
|
|
|
logHelper.Info(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异常日志输出
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
/// <param name="ex"></param>
|
|
|
|
|
private void PrintLogErrorMessage(string message, Exception ex = null)
|
|
|
|
|
{
|
|
|
|
|
RefreshLogMessageEvent?.Invoke(message);
|
|
|
|
|
logHelper.Error(message, ex);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|