From d100db102ded4dc2047f1b92f4ed0ed4c18d8ee4 Mon Sep 17 00:00:00 2001
From: Huangxiaoqiang-03 <1247017146@qq.com>
Date: 星期一, 11 十一月 2024 13:56:48 +0800
Subject: [PATCH] 1
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 95 ++++++++++++++---------------------------------
1 files changed, 28 insertions(+), 67 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index 6900e9a..e050312 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -1,5 +1,6 @@
锘縰sing HslCommunication;
using Microsoft.AspNetCore.Components.Routing;
+using Newtonsoft.Json;
using Quartz;
using SqlSugar.Extensions;
using System;
@@ -7,8 +8,10 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net;
+using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
+using WIDESEA_Common.Log;
using WIDESEA_Core.Enums;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_ITaskInfoRepository;
@@ -44,49 +47,30 @@
try
{
SpeStackerCrane speStackerCrane = (SpeStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
- GetStackerObject getStackerObject = new GetStackerObject();
+ GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
if (speStackerCrane != null)
{
- if (getStackerObject.StackerCraneTaskCompletedValue(speStackerCrane) == StackerCraneTaskCompleted.WorkCompleted)
+ if (!getStackerObject.IsEventSubscribed)
{
- _taskService.StackCraneTaskCompleted(speStackerCrane.CurrentTaskNum);
- speStackerCrane.SetValue(StackerCraneDBName.WorkType, 2);
+ getStackerObject.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
}
- else
+ if (getStackerObject.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && getStackerObject.StackerCraneStatusValue == StackerCraneStatus.Ready)
{
- if (getStackerObject.StackerCraneAutoStatusValue(speStackerCrane) == StackerCraneAutoStatus.Automatic && getStackerObject.StackerCraneStatusValue(speStackerCrane) == StackerCraneStatus.Ready)
+ getStackerObject.CheckStackerCraneTaskCompleted();//妫�娴嬪畬鎴愪簨浠�
+
+ if(getStackerObject.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
{
- if (getStackerObject.StackerCraneWorkStatusValue(speStackerCrane) == StackerCraneWorkStatus.Standby)
+ Dt_Task? task = GetTask(speStackerCrane);
+ if (task != null)
{
- Dt_Task? task = GetTask(speStackerCrane);
- if (task != null)
+ StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
+ if (stackerCraneTaskCommand != null)
{
- if (task.TaskType == TaskTypeGroup.OutbondGroup.ObjToInt())
+ bool sendFlag = getStackerObject.SendCommand(stackerCraneTaskCommand);
+ if (sendFlag)
{
- //todo鍑哄簱鍒ゆ柇璐ф灦鐘舵��
- StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
- if (stackerCraneTaskCommand != null)
- {
- bool sendFlag = speStackerCrane.SendCommand(stackerCraneTaskCommand);
- if (sendFlag)
- {
- speStackerCrane.LastTaskType = task.TaskType;
- _taskService.UpdateTaskStatusToNext(task.TaskNum);
- }
- }
- }
- else
- {
- StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
- if (stackerCraneTaskCommand != null)
- {
- bool sendFlag = speStackerCrane.SendCommand(stackerCraneTaskCommand);
- if (sendFlag)
- {
- speStackerCrane.LastTaskType = task.TaskType;
- _taskService.UpdateTaskStatusToNext(task.TaskNum);
- }
- }
+ speStackerCrane.LastTaskType = task.TaskType;
+ _taskService.UpdateTaskStatusToNext(task.TaskNum);
}
}
}
@@ -96,7 +80,7 @@
}
catch (Exception ex)
{
- //Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString());
+ WriteLog.GetLog($"鍫嗗灈鏈哄紓甯�").Write($"{nameof(CommonStackerCraneJob)}:{ex.Message}", "鍫嗗灈鏈哄紓甯�");
}
return Task.CompletedTask;
}
@@ -127,7 +111,7 @@
/// <returns></returns>
private Dt_Task? GetTask(SpeStackerCrane speStackerCrane)
{
- Dt_Task task;
+ Dt_Task? task;
if (speStackerCrane.LastTaskType == null)
{
task = _taskService.QueryStackerCraneTask(speStackerCrane.DeviceCode);
@@ -135,7 +119,7 @@
else
{
bool flag = speStackerCrane.LastTaskType == TaskTypeEnum.Inbound.ObjToInt() || speStackerCrane.LastTaskType == TaskTypeEnum.PalletInbound.ObjToInt();
- if (flag==false)
+ if (flag == false)
{
task = _taskService.QueryStackerCraneInTask(speStackerCrane.DeviceCode);
if (task == null)
@@ -181,35 +165,13 @@
}
return null;
}
-
- public bool SendCommands(StackerCraneTaskCommand command,SpeStackerCrane speStackerCrane)
- {
- try
- {
- speStackerCrane.SetValue(StackerCraneDBName.TaskNum, command.TaskNum);
- speStackerCrane.SetValue(StackerCraneDBName.StartRow, command.StartRow);
- speStackerCrane.SetValue(StackerCraneDBName.StartColumn, command.StartColumn);
- speStackerCrane.SetValue(StackerCraneDBName.StartLayer, command.StartLayer);
- speStackerCrane.SetValue(StackerCraneDBName.EndRow, command.EndRow);
- speStackerCrane.SetValue(StackerCraneDBName.EndColumn, command.EndColumn);
- speStackerCrane.SetValue(StackerCraneDBName.EndLayer, command.EndLayer);
- speStackerCrane.SetValue(StackerCraneDBName.Barcode, command.Barcode);
- speStackerCrane.SetValue(StackerCraneDBName.WorkType, command.WorkType);
- speStackerCrane.SetValue(StackerCraneDBName.TrayType, command.TrayType);
- return true;
- }
- catch (Exception ex)
- {
- return false;
- }
- }
- /// <summary>
- /// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel
- /// </summary>
- /// <param name="task">浠诲姟瀹炰綋</param>
- /// <returns></returns>
- /// <exception cref="Exception"></exception>
- public StackerCraneTaskCommand? ConvertToStackerCraneTaskCommand([NotNull] Dt_Task task)
+ /// <summary>
+ /// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel
+ /// </summary>
+ /// <param name="task">浠诲姟瀹炰綋</param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
+ public StackerCraneTaskCommand? ConvertToStackerCraneTaskCommand([NotNull] Dt_Task task)
{
StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand();
@@ -329,6 +291,5 @@
}
return stackerCraneTaskCommand;
}
-
}
}
--
Gitblit v1.9.3