From a89f1faab22c204627d49d6731be9c94d8160184 Mon Sep 17 00:00:00 2001 From: duyongjia <adu_555@163.com> Date: 星期五, 22 十一月 2024 11:23:47 +0800 Subject: [PATCH] 优化修改提交 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 59 +++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 41 insertions(+), 18 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 3e63582..2d2c8a0 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 System; using System.Collections.Generic; @@ -7,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using WIDESEAWCS_Common.ServiceLog; using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Communicator; using WIDESEAWCS_Core.Enums; @@ -47,7 +49,10 @@ public Task Execute(IJobExecutionContext context) { - CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); + WriteDebug("澶у爢鍨涙満杩愯鏃ュ織", "寮�濮嬫椂闂�" + DateTime.Now); + WriteDebug("澶у爢鍨涙満杩愯鏃ュ織", $"澶у爢鍨涙満浠诲姟鎵ц涓�..."); + //CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); + CommonStackerCrane commonStackerCrane = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC01") as CommonStackerCrane; try { if (commonStackerCrane != null) @@ -66,6 +71,7 @@ Dt_Task? task = GetTask(commonStackerCrane); if (task != null) { + WriteDebug("澶у爢鍨涙満杩愯鏃ュ織", $"澶у爢鍨涙満浠诲姟鍙穥task.TaskNum}"); StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); if (stackerCraneTaskCommand != null) { @@ -106,9 +112,9 @@ //{ try { - if (commonStackerCrane != null) { + Dt_Task? task1001 = _taskService.QueryStackerCraneTaskByAGVRequest("SC01"); if (task1001 != null) { @@ -140,22 +146,25 @@ int IsWriteTwo = 0; if (task3001.SourceAddress == "SC01-002-000-001")//WMS 1001绔欑偣 { + //鎻愬崌鏈烘槸鍚﹀浜庡氨缁姸鎬� + int IsReady= commonStackerCrane.Communicator.Read<short>("DB2.0.0"); //鍐欏叆鎻愬崌淇℃伅 IsWriteOne = commonStackerCrane.Communicator.Read<short>("DB1.0.0"); - if(IsWriteOne == 0) + if(IsWriteOne == 0&& IsReady == 1) { - - commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1); + commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1); } //璇诲彇鎻愬崌鏈轰俊鍙凤紝纭畾鏄惁鎻愬崌瀹屾垚 - commonStackerCrane.Communicator.Read<short>("DB2.2.0"); + IsFinish= commonStackerCrane.Communicator.Read<short>("DB2.2.0"); } else if (task3001.SourceAddress == "SC01-002-000-002")//WMS 1002绔欑偣 { + //鎻愬崌鏈烘槸鍚﹀浜庡氨缁姸鎬� + int IsReady = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); //鍐欏叆鎻愬崌淇℃伅 IsWriteTwo = commonStackerCrane.Communicator.Read<short>("DB1.6.0"); - if (IsWriteTwo == 0) + if (IsWriteTwo == 0 && IsReady == 1) { commonStackerCrane.Communicator.Write<short>("DB1.6.0", 1); } @@ -166,11 +175,13 @@ { MESSendCMD sendcmd = new MESSendCMD { cmd = 2002, task_id = task3001.TaskNum, status = 6 }; MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); + string inparam = JsonConvert.SerializeObject(sendcmd); + WriteDebug(nameof(CommonStackerCraneJob), $"鎻愬崌鏈烘彁鍗囧畬鎴愶紝鍥炰紶WMS,鍏ュ弬锛歿inparam}"); + if (res != null && res.code != 0) { WriteDebug(nameof(CommonStackerCraneJob), $"鎻愬崌鏈烘彁鍗囧畬鎴愶紝鍥炰紶WMS澶辫触锛佷换鍔″彿{task3001.TaskNum}"); } - } } @@ -188,8 +199,12 @@ if (!string.IsNullOrEmpty(Levels[0]) && !string.IsNullOrEmpty(Levels[1])) { int level = Convert.ToInt16(Levels[0]) - Convert.ToInt16(Levels[1]); + //鍓╀綑灞傛暟鍐欏叆 bool issuccess = commonStackerCrane.Communicator.Write<short>("DB28." + location.Depth + ".0", Convert.ToInt16(level)); + WriteDebug(nameof(CommonStackerCraneJob), $"鍓╀綑灞傛暟淇″彿鍐欏叆{level}-浠诲姟鍙穥taskSmall.TaskNum}"); + + //濡傛灉褰撳墠鎻愬彇灞傛暟绛変簬鎬诲眰鏁帮紝鍒欒〃绀烘枡杞︽墍鏈夌殑灞傛暟鍙栧畬 if (level == 0) { @@ -198,8 +213,21 @@ { //鏍规嵁鐩爣鍦板潃鏌ヨ缁勭珛鏈虹珯鐐逛俊鎭紝鑾峰彇鍐欏叆鏁磋溅瀹屾垚鐨凞B鍧� Depth Dt_LocationInfo location2 = _locationInfoRepository.QueryFirst(x => x.LocationCode == location.Remark); - //鏁磋溅瀹屾垚鍐欏叆 - bool issuccess2 = commonStackerCrane.Communicator.Write<short>("DB28." + location.Depth+".0", 1); + //鏁磋溅瀹屾垚鍐欏叆灞傛暟 + int sn = 0; + if(taskSmall.SourceAddress== "SC01-001-006-001"|| taskSmall.SourceAddress == "SC01-001-012-001"|| taskSmall.SourceAddress == "SC01-001-018-001" || taskSmall.SourceAddress == "SC01-001-022-001"|| taskSmall.SourceAddress == "SC01-001-026-001") + { + sn = 1; + } + else if(taskSmall.SourceAddress == "SC01-001-007-001" || taskSmall.SourceAddress == "SC01-001-013-001" || taskSmall.SourceAddress == "SC01-001-019-001" || taskSmall.SourceAddress == "SC01-001-023-001" || taskSmall.SourceAddress == "SC01-001-027-001") + { + sn = 2; + } + else + { + sn = 3; + } + bool issuccess2 = commonStackerCrane.Communicator.Write<short>("DB28." + location2.Depth+".0", Convert.ToInt16(sn)); if (issuccess2&&issuccess) { _taskService.UpdateTaskStatus(taskSmall.TaskId, (int)TaskOutStatusEnum.OutFinish); @@ -231,20 +259,15 @@ } } - - - } + + } } catch (Exception ex) { WriteError(nameof(CommonStackerCraneJob), "鏌ヨ鎴栧啓鍏LC鐘舵�佸け璐ワ紒", ex); } - - + WriteDebug("澶у爢鍨涙満杩愯鏃ュ織", "缁撴潫鏃堕棿" + DateTime.Now); //}); - - - return Task.CompletedTask; } -- Gitblit v1.9.3