From daf541c51a7687b338e17b1543266bacee4ff2d3 Mon Sep 17 00:00:00 2001
From: duyongjia <adu_555@163.com>
Date: 星期四, 09 一月 2025 09:34:53 +0800
Subject: [PATCH] 同步上游系统job修改
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 98 +++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 82 insertions(+), 16 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index edfd8e8..bb707d9 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -4,10 +4,14 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
+using WIDESEAWCS_Common.Http;
using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
@@ -21,7 +25,7 @@
namespace WIDESEAWCS_Tasks
{
[DisallowConcurrentExecution]
- public class CommonStackerCraneJob : IJob
+ public class CommonStackerCraneJob :JobBase, IJob
{
private readonly ITaskService _taskService;
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
@@ -35,49 +39,71 @@
_taskRepository = taskRepository;
_routerService = routerService;
}
-
+ public string url = AppSettings.Configuration["WMS"];
public Task Execute(IJobExecutionContext context)
{
+ CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
try
{
-
- CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
+ //CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
if (commonStackerCrane != null)
{
- if (!commonStackerCrane.IsEventSubscribed)
- {
- commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
- }
+ //if (!commonStackerCrane.IsEventSubscribed)
+ //{
+ // commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
+ //}
if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal)
{
- commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
+ //commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
{
+ WriteDebug(nameof(CommonStackerCraneJob), $"鍫嗗灈鏈哄紑濮嬫墽琛岋紝鑾峰彇浠诲姟鍙�");
Dt_Task? task = GetTask(commonStackerCrane);
if (task != null)
{
+ WriteDebug(nameof(CommonStackerCraneJob), $"鍫嗗灈鏈哄紑濮嬫墽琛岋紝浠诲姟鍙凤細{task.TaskNum}");
StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
int isIn = commonStackerCrane.Communicator.Read<byte>("DB106.12.0");
- if(task.TaskType == (int)TaskOutboundTypeEnum.Outbound&&isIn==1)//濡傛灉鍦ㄥ叆搴撲腑锛屼笉鍏佽涓嬪彂鍑哄簱浠诲姟
+ if((task.TaskType == (int)TaskOutboundTypeEnum.Outbound|| task.TaskType == (int)TaskOutboundTypeEnum.OutInventory) &&isIn==1)//濡傛灉鍦ㄥ叆搴撲腑锛屼笉鍏佽涓嬪彂鍑哄簱浠诲姟
{
- return Task.CompletedTask;
+ WriteDebug(nameof(CommonStackerCraneJob), $"鍑哄簱鏍¢獙锛屽湪鍏ュ簱涓紝涓嶅厑璁′笅鍙戝嚭搴撶被鍨嬩换鍔★紝浠诲姟鍙凤細{task.TaskNum}");
+ return Task.CompletedTask;
}
if (stackerCraneTaskCommand != null)
{
bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
if (sendFlag)
{
- if (task.TaskType == (int)TaskInboundTypeEnum.Inbound)
+ if (task.TaskType == (int)TaskInboundTypeEnum.Inbound|| task.TaskType == (int)TaskInboundTypeEnum.InInventory||task.TaskType==(int)TaskInboundTypeEnum.InPick)
{
_taskService.UpdateTaskStatus(task.TaskId, (int)TaskInStatusEnum.SC_InExecuting);
_taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄叆搴撴墽琛屼腑");
+ WriteDebug(nameof(CommonStackerCraneJob), $"WCS鍫嗗灈鏈哄叆搴撴墽琛屼腑锛屽紑濮嬪洖鍐橶MS浠诲姟鐘舵�侊紝浠诲姟鍙凤細{task.TaskNum}");
+ var response = HttpHelpers.Post<WebResponseContent>(url.Replace("PDA", "Task") + "UpdateTaskStatus?taskNum=" + task.TaskNum, "", "鏇存柊浠诲姟鐘舵��");
+ if(response.Status==true)
+ {
+ WriteDebug(nameof(CommonStackerCraneJob), $"WCS鍫嗗灈鏈哄叆搴撴墽琛屼腑锛屽洖鍐橶MS浠诲姟鐘舵�佹垚鍔燂紝浠诲姟鍙凤細{task.TaskNum}");
+ }
+ else
+ {
+ WriteDebug(nameof(CommonStackerCraneJob), $"WCS鍫嗗灈鏈哄叆搴撴墽琛屼腑锛屽洖鍐橶MS浠诲姟鐘舵�佸け璐ワ紝浠诲姟鍙凤細{task.TaskNum}锛屽け璐ュ師鍥爗response.Message}");
+ }
}
- else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+ else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound|| task.TaskType == (int)TaskOutboundTypeEnum.OutInventory)
{
_taskService.UpdateTaskStatus(task.TaskId, (int)TaskOutStatusEnum.SC_OutExecuting);
_taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撴墽琛屼腑");
+ var response = HttpHelpers.Post<WebResponseContent>(url.Replace("PDA", "Task") + "UpdateTaskStatus?taskNum=" + task.TaskNum, "", "鏇存柊浠诲姟鐘舵��");
+ if (response.Status == true)
+ {
+ WriteDebug(nameof(CommonStackerCraneJob), $"WCS鍫嗗灈鏈哄叆搴撴墽琛屼腑锛屽洖鍐橶MS浠诲姟鐘舵�佹垚鍔燂紝浠诲姟鍙凤細{task.TaskNum}");
+ }
+ else
+ {
+ WriteDebug(nameof(CommonStackerCraneJob), $"WCS鍫嗗灈鏈哄叆搴撴墽琛屼腑锛屽洖鍐橶MS浠诲姟鐘舵�佸け璐ワ紝浠诲姟鍙凤細{task.TaskNum}锛屽け璐ュ師鍥爗response.Message}");
+ }
}
}
}
@@ -88,8 +114,40 @@
}
catch (Exception ex)
{
- Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString());
+ WriteDebug(nameof(CommonStackerCraneJob), $"鍫嗗灈鏈烘墽琛屽紓甯革紝{ex.Message}");
}
+
+ try
+ {
+ if (commonStackerCrane != null)
+ {
+ //璇诲彇澶у爢鍨涙満浠诲姟鍙峰拰浠诲姟瀹屾垚纭鐘舵�侊紙鍥犱负灏佽鐨勪簨浠剁粡甯镐笉瑙﹀彂锛屾墍浠ュ姞涓洿鎺ヨ鐨勯�昏緫锛屼互鍏嶅嚭鐜板爢鍨涙満涓�鐩存帴澶勪簬绛夊緟wcs纭锛�
+ byte IsOver = commonStackerCrane.Communicator.Read<byte>("DB106.22");
+ int tasknum = commonStackerCrane.Communicator.Read<int>("DB106.18");
+ //WriteDebug(nameof(CommonStackerCraneJob), $"澶у爢鍨涙満SC01浠诲姟鍙峰爢鍨涙満浠诲姟鍙凤細{tasknum}鐘舵�侊細{IsOver}");
+ if (IsOver == 6)
+ {
+ if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
+ {
+ _taskService.StackCraneTaskCompleted(tasknum);
+ WriteDebug(nameof(CommonStackerCraneJob), $"鍫嗗灈鏈篧CS浠诲姟鎵ц瀹屾垚锛屼换鍔″彿锛歿tasknum}");
+ Console.Out.WriteLine("TaskCompleted" + tasknum);
+ bool issuccess = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
+ if (issuccess)
+ {
+ WriteDebug(nameof(CommonStackerCraneJob), $"鍫嗗灈鏈轰换鍔″彿锛歿tasknum},鍫嗗灈鏈哄洖鍐�5鎴愬姛");
+
+ }
+ }
+ }
+ }
+ }
+ catch(Exception ex)
+ {
+ WriteDebug(nameof(CommonStackerCraneJob), $"鍫嗗灈鏈轰换鍔″畬鎴愬紓甯革紝{ex.Message}");
+ }
+
+
return Task.CompletedTask;
}
@@ -120,7 +178,7 @@
private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
{
Dt_Task task;
- task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
+ task = _taskService.QueryStackerCraneTask("R01");
return task;
}
@@ -168,7 +226,15 @@
stackerCraneTaskCommand.Barcode = task.PalletCode;
stackerCraneTaskCommand.TaskNum = task.TaskNum;
stackerCraneTaskCommand.WorkType = 1;
- stackerCraneTaskCommand.TrayType = 1;
+ if(task.PalletCode.Substring(0,1)=="B")
+ {
+ stackerCraneTaskCommand.TrayType = 2;
+ }
+ else
+ {
+ stackerCraneTaskCommand.TrayType = 1;
+ }
+ //stackerCraneTaskCommand.TrayType = 1;
string[] SourceCodes = task.SourceAddress.Split("-");
if (SourceCodes.Length == 4)
{
--
Gitblit v1.9.3