From 0c0ac28fc5784ac64612811c65be7dca8318d8c6 Mon Sep 17 00:00:00 2001 From: duyongjia <adu_555@163.com> Date: 星期二, 26 十一月 2024 21:23:19 +0800 Subject: [PATCH] 前端更新货位状态修改 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 242 ++++++++++++++++++++++++++--------------------- 1 files changed, 133 insertions(+), 109 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 2d2c8a0..6250472 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" @@ -110,116 +110,140 @@ //鏌ヨ鎻愬崌鏈�/缁勭珛鏈轰俊鍙� //Task.Run(delegate //{ - try + try + { + if (commonStackerCrane != null) { - if (commonStackerCrane != null) + + Dt_Task? task1001 = _taskService.QueryStackerCraneTaskByAGVRequest("SC01"); + if (task1001 != null) { - - Dt_Task? task1001 = _taskService.QueryStackerCraneTaskByAGVRequest("SC01"); - if (task1001 != null) + //璇诲彇鎻愬崌鏈轰俊鍙凤紝纭畾鏄惁鍙互杩涘叆 + int IsAllow = 0; + if (task1001.SourceAddress == "SC01-002-000-001")//WMS 1001绔欑偣 { - //璇诲彇鎻愬崌鏈轰俊鍙凤紝纭畾鏄惁鍙互杩涘叆 - int IsAllow = 0; - if (task1001.SourceAddress == "SC01-002-000-001")//WMS 1001绔欑偣 + IsAllow = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); + } + else if (task1001.SourceAddress == "SC01-002-000-002")//WMS 1002绔欑偣 + { + IsAllow = commonStackerCrane.Communicator.Read<short>("DB2.8.0"); + } + if (IsAllow == 1)//濡傛灉涓�1锛屽垯鍏佽AGV杩涘叆锛屽洖浼燱MS + { + MESSendCMD sendcmd = new MESSendCMD { cmd = 2001, task_id = task1001.TaskNum, status = 6 }; + MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); + if (res != null && res.code != 0) { - IsAllow = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); + WriteDebug(nameof(CommonStackerCraneJob), $"鍏佽AGV杩涘叆鎻愬崌鏈猴紝鍥炰紶WMS澶辫触锛佷换鍔″彿{task1001.TaskNum}"); } - else if (task1001.SourceAddress == "SC01-002-000-002")//WMS 1002绔欑偣 + else { - IsAllow = commonStackerCrane.Communicator.Read<short>("DB2.8.0"); - } - if (IsAllow == 1)//濡傛灉涓�1锛屽垯鍏佽AGV杩涘叆锛屽洖浼燱MS - { - MESSendCMD sendcmd = new MESSendCMD { cmd = 2001, task_id = task1001.TaskNum, status = 6 }; - MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); - if (res != null && res.code != 0) - { - WriteDebug(nameof(CommonStackerCraneJob), $"鎻愬崌鏈烘彁鍗囧畬鎴愶紝鍥炰紶WMS澶辫触锛佷换鍔″彿{task1001.TaskNum}"); - } + WriteDebug(nameof(CommonStackerCraneJob), $"鍏佽AGV杩涘叆鎻愬崌鏈猴紝鍥炰紶WMS鎴愬姛锛佷换鍔″彿{task1001.TaskNum}"); } } - Dt_Task? task3001 = _taskService.QueryStackerCraneTaskByAGVPutFinish("SC01"); - if (task3001 != null) + else { - int IsFinish = 0; - int IsWriteOne = 0; - int IsWriteTwo = 0; - if (task3001.SourceAddress == "SC01-002-000-001")//WMS 1001绔欑偣 + WriteDebug(nameof(CommonStackerCraneJob), $"鏈鍙栧埌鎻愬崌鏈哄厑璁¤繘鍏ヤ俊鍙凤紝鏆備笉鍏佽AGV杩涘叆鎻愬崌鏈猴紝浠诲姟鍙穥task1001.TaskNum}"); + } + } + Dt_Task? task3001 = _taskService.QueryStackerCraneTaskByAGVPutFinish("SC01"); + if (task3001 != null) + { + int IsFinish = 0; + int IsWriteOne = 0; + int IsWriteTwo = 0; + if (task3001.SourceAddress == "SC01-002-000-001")//WMS 1001绔欑偣 + { + //鎻愬崌鏈烘槸鍚﹀浜庡氨缁姸鎬� + + int IsReady = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); + WriteDebug(nameof(CommonStackerCraneJob), $"鎻愬崌鏈虹姸鎬侊細{IsReady}浠诲姟鍙凤細{task3001.TaskNum}"); + //鍐欏叆鎻愬崌淇℃伅 + IsWriteOne = commonStackerCrane.Communicator.Read<short>("DB1.0.0"); + if (IsWriteOne == 0 && IsReady == 1) { - //鎻愬崌鏈烘槸鍚﹀浜庡氨缁姸鎬� - int IsReady= commonStackerCrane.Communicator.Read<short>("DB2.0.0"); - //鍐欏叆鎻愬崌淇℃伅 - IsWriteOne = commonStackerCrane.Communicator.Read<short>("DB1.0.0"); - if(IsWriteOne == 0&& IsReady == 1) - { - commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1); - } - //璇诲彇鎻愬崌鏈轰俊鍙凤紝纭畾鏄惁鎻愬崌瀹屾垚 - - IsFinish= commonStackerCrane.Communicator.Read<short>("DB2.2.0"); + commonStackerCrane.Communicator.Write<short>("DB1.0.0", 1); } - else if (task3001.SourceAddress == "SC01-002-000-002")//WMS 1002绔欑偣 + else { - //鎻愬崌鏈烘槸鍚﹀浜庡氨缁姸鎬� - int IsReady = commonStackerCrane.Communicator.Read<short>("DB2.0.0"); - //鍐欏叆鎻愬崌淇℃伅 - IsWriteTwo = commonStackerCrane.Communicator.Read<short>("DB1.6.0"); - if (IsWriteTwo == 0 && IsReady == 1) - { - commonStackerCrane.Communicator.Write<short>("DB1.6.0", 1); - } - //璇诲彇鎻愬崌鏈轰俊鍙凤紝纭畾鏄惁鎻愬崌瀹屾垚 - IsFinish = commonStackerCrane.Communicator.Read<short>("DB2.10.0"); + WriteDebug(nameof(CommonStackerCraneJob), $"鏈啓鍏ユ彁鍗囦俊鍙凤紝鍙兘鏄凡鍐欏叆鎴栬�呮彁鍗囨満鏈鐞嗗氨缁姸鎬�,浠诲姟鍙凤細{task3001.TaskNum}"); } - if (IsFinish == 1)//濡傛灉涓�1锛屽垯琛ㄧず鎻愬崌瀹屾垚锛屽洖浼燱MS - { - 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}"); - } + 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"); + WriteDebug(nameof(CommonStackerCraneJob), $"鎻愬崌鏈虹姸鎬侊細{IsReady}浠诲姟鍙凤細{task3001.TaskNum}"); + //鍐欏叆鎻愬崌淇℃伅 + IsWriteTwo = commonStackerCrane.Communicator.Read<short>("DB1.6.0"); + if (IsWriteTwo == 0 && IsReady == 1) + { + commonStackerCrane.Communicator.Write<short>("DB1.6.0", 1); + } + else + { + WriteDebug(nameof(CommonStackerCraneJob), $"鏈啓鍏ユ彁鍗囦俊鍙凤紝鍙兘鏄俊鍙峰凡鍐欏叆鎴栬�呮彁鍗囨満鏈鐞嗗氨缁姸鎬侊紝浠诲姟鍙凤細{task3001.TaskNum}"); + } + //璇诲彇鎻愬崌鏈轰俊鍙凤紝纭畾鏄惁鎻愬崌瀹屾垚 + IsFinish = commonStackerCrane.Communicator.Read<short>("DB2.10.0"); + } + if (IsFinish == 1)//濡傛灉涓�1锛屽垯琛ㄧず鎻愬崌瀹屾垚锛屽洖浼燱MS + { + 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}"); } } - - //灏忓爢鍨涙満鍑哄簱瀹屾垚浠诲姟 - Dt_Task? taskSmall = _taskService.QueryStackerCraneFinishTask(); - if(taskSmall != null) + else { - //鏍规嵁浠诲姟婧愬湴鍧�纭畾鍐欏叆PLC浣嶇疆 Depth - Dt_LocationInfo location = _locationInfoRepository.QueryFirst(x=>x.LocationCode==taskSmall.SourceAddress); - if(location != null) + WriteDebug(nameof(CommonStackerCraneJob), $"鎻愬崌鏈烘彁鍗囦腑...锛屼换鍔″彿锛歿task3001.TaskNum}"); + } + } + + //灏忓爢鍨涙満鍑哄簱瀹屾垚浠诲姟 + Dt_Task? taskSmall = _taskService.QueryStackerCraneFinishTask(); + if (taskSmall != null) + { + //鏍规嵁浠诲姟婧愬湴鍧�纭畾鍐欏叆PLC浣嶇疆 Depth + Dt_LocationInfo location = _locationInfoRepository.QueryFirst(x => x.LocationCode == taskSmall.SourceAddress); + if (location != null) + { + string[] Levels = taskSmall.Remark.Split("-"); + if (Levels.Length == 2) { - string[] Levels = taskSmall.Remark.Split("-"); - if (Levels.Length == 2) + if (!string.IsNullOrEmpty(Levels[0]) && !string.IsNullOrEmpty(Levels[1])) { - 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) { - 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) + //婧愬湴鍧�锛堟殏瀛樹綅锛夊搴旂殑鐩爣鍦板潃锛堢粍绔嬫満锛塴ocation.Remark + if (!string.IsNullOrEmpty(location.Remark)) { - //婧愬湴鍧�锛堟殏瀛樹綅锛夊搴旂殑鐩爣鍦板潃锛堢粍绔嬫満锛塴ocation.Remark - if (!string.IsNullOrEmpty(location.Remark)) - { - //鏍规嵁鐩爣鍦板潃鏌ヨ缁勭珛鏈虹珯鐐逛俊鎭紝鑾峰彇鍐欏叆鏁磋溅瀹屾垚鐨凞B鍧� Depth - Dt_LocationInfo location2 = _locationInfoRepository.QueryFirst(x => x.LocationCode == location.Remark); + //鏍规嵁鐩爣鍦板潃鏌ヨ缁勭珛鏈虹珯鐐逛俊鎭紝鑾峰彇鍐欏叆鏁磋溅瀹屾垚鐨凞B鍧� Depth + Dt_LocationInfo location2 = _locationInfoRepository.QueryFirst(x => x.LocationCode == location.Remark); //鏁磋溅瀹屾垚鍐欏叆灞傛暟 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") + 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") + 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; } @@ -227,45 +251,45 @@ { 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); - _taskExecuteDetailService.AddTaskExecuteDetail(taskSmall.TaskId, $"鍑哄簱浠诲姟瀹屾垚"); - } - else - { - WriteDebug(nameof(CommonStackerCraneJob), $"鏁磋溅瀹屾垚淇″彿鍐欏叆澶辫触锛佷换鍔″彿{taskSmall.TaskNum}"); - } - } - - } - else - { - - if (issuccess) + bool issuccess2 = commonStackerCrane.Communicator.Write<short>("DB28." + location2.Depth + ".0", Convert.ToInt16(sn)); + if (issuccess2 && issuccess) { _taskService.UpdateTaskStatus(taskSmall.TaskId, (int)TaskOutStatusEnum.OutFinish); _taskExecuteDetailService.AddTaskExecuteDetail(taskSmall.TaskId, $"鍑哄簱浠诲姟瀹屾垚"); } else { - WriteDebug(nameof(CommonStackerCraneJob), $"鍓╀綑灞傛暟淇″彿鍐欏叆澶辫触锛佷换鍔″彿{taskSmall.TaskNum}"); + WriteDebug(nameof(CommonStackerCraneJob), $"鏁磋溅瀹屾垚淇″彿鍐欏叆澶辫触锛佷换鍔″彿{taskSmall.TaskNum}"); } } } + else + { + + if (issuccess) + { + _taskService.UpdateTaskStatus(taskSmall.TaskId, (int)TaskOutStatusEnum.OutFinish); + _taskExecuteDetailService.AddTaskExecuteDetail(taskSmall.TaskId, $"鍑哄簱浠诲姟瀹屾垚"); + } + else + { + WriteDebug(nameof(CommonStackerCraneJob), $"鍓╀綑灞傛暟淇″彿鍐欏叆澶辫触锛佷换鍔″彿{taskSmall.TaskNum}"); + } + } + } } - } - + + } + } - } - catch (Exception ex) - { - WriteError(nameof(CommonStackerCraneJob), "鏌ヨ鎴栧啓鍏LC鐘舵�佸け璐ワ紒", ex); - } + } + catch (Exception ex) + { + WriteError(nameof(CommonStackerCraneJob), "鏌ヨ鎴栧啓鍏LC鐘舵�佸け璐ワ紒", ex); + } WriteDebug("澶у爢鍨涙満杩愯鏃ュ織", "缁撴潫鏃堕棿" + DateTime.Now); //}); return Task.CompletedTask; -- Gitblit v1.9.3