From cb385f0b515c738b503c5c75c9d7efcec323716d Mon Sep 17 00:00:00 2001 From: duyongjia <adu_555@163.com> Date: 星期五, 28 二月 2025 09:12:40 +0800 Subject: [PATCH] 数据库脚本提交 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 434 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 408 insertions(+), 26 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" index dd4bf5a..e735e1a 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" @@ -24,6 +24,7 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +using System.Data; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; @@ -42,6 +43,7 @@ using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; +using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.Models; using WIDESEAWCS_QuartzJob.Service; @@ -210,7 +212,7 @@ if (taskinfo != null) { UpdateTaskStatus(taskinfo.TaskId, (int)TaskInStatusEnum.AGV_InExecuting); - _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"AGV鍏ュ簱鎵ц涓�"); + _taskExecuteDetailService.AddTaskExecuteDetail(taskinfo.TaskId, $"AGV鍏ュ簱鎵ц涓�"); ServiceLogger.WriteDebug("ReceiveTask", $"AGV鍏ュ簱鎵ц涓紙鑷姩3001锛夋洿鏂扮姸鎬佹垚鍔燂紝浠诲姟鍙凤細{taskinfo.TaskId}"); return content = WebResponseContent.Instance.OK($"AGV鍏ュ簱鎵ц涓紙鑷姩3001锛夋洿鏂扮姸鎬佹垚鍔燂紝浠诲姟鍙凤細{taskinfo.TaskId}"); } @@ -226,7 +228,7 @@ { //鏇存柊浠诲姟琛ㄤ腑NextAddress瀛楁涓烘柊鐨勪换鍔″彿 taskDTO.weight-鏃х殑浠诲姟鍙� taskDTO.task_id-鏂扮殑浠诲姟鍙� UpdateTaskStatus(taskinfo.TaskId, taskDTO.task_id, (int)TaskInStatusEnum.AGV_InFinish); - _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"AGV鎼繍瀹屾垚"); + _taskExecuteDetailService.AddTaskExecuteDetail(taskinfo.TaskId, $"AGV鎼繍瀹屾垚"); ServiceLogger.WriteDebug("ReceiveTask", $"AGV鎼繍瀹屾垚锛�101锛夋洿鏂扮姸鎬佹垚鍔燂紝浠诲姟鍙凤細{taskinfo.TaskId}"); return content = WebResponseContent.Instance.OK($"AGV鎼繍瀹屾垚锛�101锛夋洿鏂扮姸鎬佹垚鍔燂紝浠诲姟鍙凤細{taskinfo.TaskId}"); } @@ -241,6 +243,10 @@ task.TaskType= (int)TaskRelocationTypeEnum.Relocation; task.TaskState = (int)TaskOutStatusEnum.OutNew; task.Roadway = "SC01"; + if (taskDTO.total > 0) + { + task.Remark = taskDTO.total.ToString();//鍙栧嚭搴撶殑鎬诲眰鏁� + } task.Grade = 1; break; case 102: @@ -478,6 +484,253 @@ } + + /// <summary> + /// wcs鎵嬪伐鐢熸垚浠诲姟 + /// </summary> + /// <param name="taskDTO">WCS浠诲姟瀵硅薄</param> + /// <returns>杩斿洖澶勭悊缁撴灉</returns> + public WebResponseContent ReceiveWCSTask([NotNull] MESTaskDTO taskDTO) + { + WebResponseContent content = new WebResponseContent(); + try + { + taskDTO.task_id = GetTaskNo(); + string inparam = JsonConvert.SerializeObject(taskDTO); + + ServiceLogger.WriteDebug("ReceiveWCSTask", $"ReceiveWCSTask鏂规硶鍏ュ弬{inparam}"); + Dt_Task task = new Dt_Task(); + Dt_Task taskinfo = BaseDal.QueryFirst(x => x.TaskNum == taskDTO.task_id); + if (taskDTO.cmd == 101)//濡傛灉鏄�101鎸夋棫鐨勪换鍔″彿鍘绘煡 + { + taskinfo = BaseDal.QueryFirst(x => x.TaskNum == taskDTO.weight); + } + + if (taskDTO.cmd != 3001 && taskDTO.cmd != 101 && taskinfo != null) + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"浠诲姟鍙烽噸澶嶏紝浠诲姟鍙凤細{taskDTO.task_id}"); + return content = WebResponseContent.Instance.Error($"浠诲姟鍙烽噸澶嶏紝浠诲姟鍙凤細{taskDTO.task_id}"); + } + Dt_LocationInfo locationsrc = _locationInfoRepository.QueryFirst(x => x.Remark == taskDTO.src_station.ToString()); + Dt_LocationInfo locationdsc = _locationInfoRepository.QueryFirst(x => x.Remark == taskDTO.dest_station.ToString()); + switch (taskDTO.cmd) + { + case 3001://AGV鏀捐揣瀹屾垚 WMS鍙�3001鐨勫悓鏃禬CS闇�鍦╦ob涓啓鎻愬崌淇″彿 + if (BaseDal.QueryFirst(x => x.TaskNum == taskDTO.task_id) == null)//鎵嬪姩鍏ュ簱鐩存帴鍙�3001锛岄渶瑕佺敓鎴愪换鍔★紝鍥犱负娌℃湁1001鐜妭 + { + taskDTO.dest_rack =int.Parse(taskDTO.dest_station.ToString().Substring(0, 1)); + taskDTO.dest_row = int.Parse(taskDTO.dest_station.ToString().Substring(1, 2).TrimStart('0')); + taskDTO.dest_col = int.Parse(taskDTO.dest_station.ToString().Substring(3, 2).TrimStart('0')); + task.TaskType = (int)TaskInboundTypeEnum.Inbound; + task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting; + task.Roadway = "SC01"; + task.Grade = 2; + + if (locationsrc != null) + { + task.SourceAddress = locationsrc.LocationCode; + } + else + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"WCS鏈煡璇㈠埌婧愮珯鐐瑰搴旂殑搴撲綅锛屾簮绔欑偣锛歿taskDTO.dest_station.ToString()}"); + return content = WebResponseContent.Instance.Error($"WCS鏈煡璇㈠埌婧愮珯鐐瑰搴旂殑搴撲綅锛屾簮绔欑偣锛歿taskDTO.dest_station.ToString()}"); + } + } + break; + case 101://鎻愬崌鏈烘彁鍗囧畬鎴� + if (taskinfo != null) + { + //鏇存柊浠诲姟琛ㄤ腑NextAddress瀛楁涓烘柊鐨勪换鍔″彿 taskDTO.weight-鏃х殑浠诲姟鍙� taskDTO.task_id-鏂扮殑浠诲姟鍙� + UpdateTaskStatus(taskinfo.TaskId, taskDTO.task_id, (int)TaskInStatusEnum.AGV_InFinish); + _taskExecuteDetailService.AddTaskExecuteDetail(taskinfo.TaskId, $"AGV鎼繍瀹屾垚"); + ServiceLogger.WriteDebug("ReceiveWCSTask", $"AGV鎼繍瀹屾垚锛�101锛夋洿鏂扮姸鎬佹垚鍔燂紝浠诲姟鍙凤細{taskinfo.TaskId}"); + return content = WebResponseContent.Instance.OK($"AGV鎼繍瀹屾垚锛�101锛夋洿鏂扮姸鎬佹垚鍔燂紝浠诲姟鍙凤細{taskinfo.TaskId}"); + } + else + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"AGV鎼繍瀹屾垚锛�101锛夋洿鏂扮姸鎬佹椂锛屾煡璇笉鍒颁换鍔″彿"); + return content = WebResponseContent.Instance.Error($"AGV鎼繍瀹屾垚锛�101锛夋洿鏂扮姸鎬佹椂锛屾煡璇笉鍒颁换鍔″彿"); + } + break; + + case 103://浜у搧绉诲簱锛堢Щ搴擄紝鍑哄簱锛� + taskDTO.src_rack = int.Parse(taskDTO.src_station.ToString().Substring(0, 1)); + taskDTO.src_row = int.Parse(taskDTO.src_station.ToString().Substring(1, 2).TrimStart('0')); + taskDTO.src_col = int.Parse(taskDTO.src_station.ToString().Substring(3, 2).TrimStart('0')); + + taskDTO.dest_rack = int.Parse(taskDTO.dest_station.ToString().Substring(0, 1)); + taskDTO.dest_row = int.Parse(taskDTO.dest_station.ToString().Substring(1, 2).TrimStart('0')); + taskDTO.dest_col = int.Parse(taskDTO.dest_station.ToString().Substring(3, 2).TrimStart('0')); + + taskDTO.total = 9; + task.TaskType = (int)TaskRelocationTypeEnum.Relocation; + task.TaskState = (int)TaskOutStatusEnum.OutNew; + task.Roadway = "SC01"; + + if (taskDTO.total > 0) + { + task.Remark = taskDTO.total.ToString();//鍙栧嚭搴撶殑鎬诲眰鏁� + } + task.Grade = 1; + break; + case 102: + if (taskDTO.dest_station == 1001 || taskDTO.dest_station == 1002)//寮傚父鍑哄簱 + { + taskDTO.src_rack = int.Parse(taskDTO.src_station.ToString().Substring(0, 1)); + taskDTO.src_row = int.Parse(taskDTO.src_station.ToString().Substring(1, 2).TrimStart('0')); + taskDTO.src_col = int.Parse(taskDTO.src_station.ToString().Substring(3, 2).TrimStart('0')); + task.TaskType = (int)TaskOutboundTypeEnum.OutInventory; + task.TaskState = (int)TaskOutStatusEnum.OutNew; + task.Roadway = "SC01"; + task.Grade = 1; + } + if (locationdsc != null) + { + task.TargetAddress = locationdsc.LocationCode; + } + else + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"WCS鏈煡璇㈠埌鐩爣绔欑偣瀵瑰簲鐨勫簱浣嶏紝鐩爣绔欑偣锛歿taskDTO.dest_station.ToString()}"); + return content = WebResponseContent.Instance.Error($"WCS鏈煡璇㈠埌鐩爣绔欑偣瀵瑰簲鐨勫簱浣嶏紝鐩爣绔欑偣锛歿taskDTO.dest_station.ToString()}"); + } + break; + default: + break; + } + + task.TaskNum = taskDTO.task_id; + task.PalletCode = taskDTO.CarId; + + if (string.IsNullOrEmpty(task.SourceAddress))//濡傛灉涓嶆槸绔欑偣锛岀洿鎺ュ彇琛屽垪灞� + { + task.SourceAddress = $"SC01-{taskDTO.src_rack.ToString().PadLeft(3, '0')}-{taskDTO.src_col.ToString().PadLeft(3, '0')}-{taskDTO.src_row.ToString().PadLeft(3, '0')}"; + } + if (string.IsNullOrEmpty(task.TargetAddress))//濡傛灉涓嶆槸绔欑偣锛岀洿鎺ュ彇琛屽垪灞� + { + task.TargetAddress = $"SC01-{taskDTO.dest_rack.ToString().PadLeft(3, '0')}-{taskDTO.dest_col.ToString().PadLeft(3, '0')}-{taskDTO.dest_row.ToString().PadLeft(3, '0')}"; + } + task.Creater = "WCS"; + task.WMSId = 3;//WCS浜哄伐寤轰换鍔� + + //鍒ゆ柇璐т綅鐘舵�� + Dt_LocationInfo srcLocation = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); + Dt_LocationInfo tarLocation = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress); + if (srcLocation != null && tarLocation != null) + { + if (srcLocation.EnableStatus == (int)EnableStatusEnum.Disable) + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"婧愬湴鍧�宸茬鐢細{srcLocation.LocationCode}"); + return content = WebResponseContent.Instance.Error($"婧愬湴鍧�宸茬鐢細{srcLocation.LocationCode}"); + } + if (tarLocation.EnableStatus == (int)EnableStatusEnum.Disable) + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"鐩爣鍦板潃宸茬鐢細{tarLocation.LocationCode}"); + return content = WebResponseContent.Instance.Error($"鐩爣鍦板潃宸茬鐢細{tarLocation.LocationCode}"); + } + if (taskDTO.cmd != 101)//鍏ュ簱鏃朵笉闇�瑕佸垽鏂槸鍚﹂攣瀹氾紝閿佸畾鐘舵�佹槸鍦ㄧ敓鎴愪换鍔℃椂閿佸畾 + { + + if (taskinfo != null && taskDTO.cmd == 3001 && taskinfo.WMSId == 3)//濡傛灉鏄墜鍔ㄥ叆搴擄紝鍙�3001锛屼細鐢熸垚浠诲姟锛岄渶瑕佸垽鏂簱浣嶆槸鍚﹂攣瀹�;鑷姩妯″紡鍙�1001鐨勬椂鍊欏氨鐢熸垚浜嗕换鍔★紝鍐嶅彂3001灏变笉闇�瑕佸垽鏂槸鍚﹂攣瀹氫簡 + { + if (srcLocation.LocationStatus == (int)LocationStatusEnum.Lock) + { + + ServiceLogger.WriteDebug("ReceiveWCSTask", $"婧愬湴鍧�宸查攣瀹氾細{srcLocation.LocationCode}"); + return content = WebResponseContent.Instance.Error($"婧愬湴鍧�宸查攣瀹氾細{srcLocation.LocationCode}"); + } + if (tarLocation.LocationStatus == (int)LocationStatusEnum.Lock) + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"鐩爣鍦板潃宸查攣瀹氾細{tarLocation.LocationCode}"); + return content = WebResponseContent.Instance.Error($"鐩爣鍦板潃宸查攣瀹氾細{tarLocation.LocationCode}"); + } + } + } + if (task.TaskType == (int)TaskInboundTypeEnum.Inbound)//鍏ュ簱 璺緞锛氭彁鍗囨満搴撲綅-->搴撲綅 + { + //WCS鏌ヨ搴撲綅鐘舵�佹槸鍚︿负鈥滅┖闂测�濆苟涓旀湭绂佺敤锛岄攣瀹氬簱浣嶄慨鏀瑰簱浣嶇姸鎬佷负鈥滈攣瀹氣�濓紝鐢熸垚WCS浜у搧鍏ュ簱浠诲姟锛屽姞鍏CS浠诲姟闃熷垪涓�� + if (tarLocation.LocationStatus != (int)LocationStatusEnum.Free) + { + + ServiceLogger.WriteDebug("ReceiveWCSTask", $"鍏ュ簱-鐩爣鍦板潃涓嶆槸绌洪棽鐘舵�侊細{tarLocation.LocationCode}"); + return content = WebResponseContent.Instance.Error($"鍏ュ簱-鐩爣鍦板潃涓嶆槸绌洪棽鐘舵�侊細{tarLocation.LocationCode}"); + } + tarLocation.LocationStatus = (int)LocationStatusEnum.Lock; + } + else if (task.TaskType == (int)TaskRelocationTypeEnum.Relocation) //浜у搧绉诲簱锛堢Щ搴擄紝鍑哄簱鍏辩敤锛� 璺緞锛氬簱浣�-->搴撲綅/鏆傚瓨搴撲綅 + { + //WCS鏌ヨ搴撲綅鐘舵�佹槸鍚︿负鈥滄湁璐р�濓紝搴撲綅/鏆傚瓨搴撲綅鏄惁鈥滅┖闂测�� + if (srcLocation.LocationStatus != (int)LocationStatusEnum.InStock) + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"绉诲簱-婧愬湴鍧�涓嶆槸鏈夎揣鐘舵�侊細{srcLocation.LocationCode}"); + return content = WebResponseContent.Instance.Error($"绉诲簱-婧愬湴鍧�涓嶆槸鏈夎揣鐘舵�侊細{srcLocation.LocationCode}"); + } + if (tarLocation.LocationStatus != (int)LocationStatusEnum.Free) + { + + ServiceLogger.WriteDebug("ReceiveWCSTask", $"绉诲簱-鐩爣鍦板潃涓嶆槸绌洪棽鐘舵�侊細{srcLocation.LocationCode}"); + return content = WebResponseContent.Instance.Error($"绉诲簱-鐩爣鍦板潃涓嶆槸绌洪棽鐘舵�侊細{srcLocation.LocationCode}"); + } + srcLocation.LocationStatus = (int)LocationStatusEnum.Lock; + tarLocation.LocationStatus = (int)LocationStatusEnum.Lock; + } + else if (task.TaskType == (int)TaskOutboundTypeEnum.OutInventory) //寮傚父鍑哄簱锛堥��搴擄級 璺緞锛氬簱浣�-->鎻愬崌鏈哄簱浣� + { + //WCS鏌ヨ搴撲綅鐘舵�佹槸鍚︿负鈥滄湁璐р�� + if (srcLocation.LocationStatus != (int)LocationStatusEnum.InStock) + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"寮傚父鍑哄簱-婧愬湴鍧�涓嶆槸鏈夎揣鐘舵�侊細{srcLocation.LocationCode}"); + return content = WebResponseContent.Instance.Error($"寮傚父鍑哄簱-婧愬湴鍧�涓嶆槸鏈夎揣鐘舵�侊細{srcLocation.LocationCode}"); + } + srcLocation.LocationStatus = (int)LocationStatusEnum.Lock; + } + } + else + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"搴撲綅鍦板潃涓嶅瓨鍦紝浠诲姟鍙�:{task.TaskNum}"); + return content = WebResponseContent.Instance.Error($"搴撲綅鍦板潃涓嶅瓨鍦紝浠诲姟鍙�:{task.TaskNum}"); + } + + try + { + //寮�鍚簨鐗� + _unitOfWorkManage.BeginTran(); + _locationInfoRepository.UpdateData(tarLocation); + _locationInfoRepository.UpdateData(srcLocation); + BaseDal.AddData(task); + Dt_Task tasktemp = BaseDal.QueryFirst(x => x.TaskNum == task.TaskNum); + _taskExecuteDetailService.AddTaskExecuteDetail(tasktemp.TaskId, "鎺ユ敹WCS浠诲姟"); + //鎻愪氦浜嬪姟 + _unitOfWorkManage.CommitTran(); + + } + catch (Exception) + { + _unitOfWorkManage.RollbackTran(); + throw; + } + ServiceLogger.WriteDebug("ReceiveWCSTask", $"鎺ユ敹浠诲姟鎴愬姛锛屼换鍔″彿:{task.TaskNum}"); + content = WebResponseContent.Instance.OK($"鎺ユ敹浠诲姟鎴愬姛锛屼换鍔″彿:{task.TaskNum}", task); + + } + catch (Exception ex) + { + ServiceLogger.WriteDebug("ReceiveWCSTask", $"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.StackTrace}"); + content = WebResponseContent.Instance.Error($"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}"); + } + return content; + } + + + /// <summary> + /// 鑾峰彇浠诲姟鍙� + /// </summary> + /// <returns></returns> + public int GetTaskNo() + { + DataTable dt = BaseDal.QueryTable("SELECT FORMAT(NEXT VALUE FOR dbo.seqTaskNum, '0000000');"); + return int.Parse("9"+ dt.Rows[0][0].ToString()); + } + /// <summary> /// 鏍规嵁鎵樼洏鍙枫�佽捣濮嬪湴鍧�鍚慦MS璇锋眰浠诲姟 /// </summary> @@ -586,6 +839,15 @@ } /// <summary> + /// 鏌ヨ绉诲簱浠诲姟 + /// </summary> + /// <returns></returns> + public Dt_Task QueryStackerCraneTaskByRelotion(int taskNum) + { + return BaseDal.QueryFirst(x => (x.Roadway == "SC01" )&&x.TaskType==(int)TaskRelocationTypeEnum.Relocation && x.TaskNum==taskNum, TaskOrderBy); + } + + /// <summary> /// 鏌ヨ灏忓爢鍨涙満鍑哄簱瀹屾垚浠诲姟 /// </summary> /// <returns></returns> @@ -600,8 +862,19 @@ /// <param name="deviceNo"></param> /// <returns></returns> public Dt_Task QueryStackerCraneTaskByAGVRequest(string deviceNo) - { + { return BaseDal.QueryFirst(x => x.Roadway == deviceNo && (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew), TaskOrderBy); + } + + /// <summary> + /// 鏌ヨAGV杩涘叆涓殑鍏ュ簱浠诲姟 + /// </summary> + /// <param name="deviceNo"></param> + /// <returns></returns> + public Dt_Task QueryStackerCraneTaskByAGVIning(string deviceNo) + { + + return BaseDal.QueryFirst(x => x.Roadway == deviceNo && (TaskInboundTypes.Contains(x.TaskType)&&x.CurrentAddress=="1"), TaskOrderBy); } /// <summary> /// 瀵瑰簲WMS璇锋眰 3001-AGV鏀捐揣瀹屾垚 @@ -691,6 +964,56 @@ } /// <summary> + /// 鑷姩鍏ュ簱鏃舵洿鏂版槸鍚﹁繘鍏ュ崌闄嶆満鏍囧織锛�0锛屾湭杩涘叆 1锛屽凡杩涘叆锛� + /// </summary> + /// <param name="taskNum"></param> + /// <param name="Inflag"></param> + /// <returns></returns> + public WebResponseContent UpdateTaskAllowIn(int taskNum, int Inflag) + { + WebResponseContent content = new WebResponseContent(); + try + { + Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); + if (task == null) return WebResponseContent.Instance.Error($"鏈壘鍒拌浠诲姟淇℃伅,浠诲姟鍙�:銆恵taskNum}銆�"); + task.CurrentAddress = Inflag.ToString(); + task.ModifyDate = DateTime.Now; + BaseDal.UpdateData(task); + } + catch (Exception ex) + { + content = WebResponseContent.Instance.Error(ex.Message); + } + return content; + + } + + /// <summary> + /// 鏄惁宸插洖浼燤ES2001鏍囧織锛�0锛屾湭鍥炰紶 1锛屽凡鍥炰紶锛� + /// </summary> + /// <param name="taskNum"></param> + /// <param name="Inflag"></param> + /// <returns></returns> + public WebResponseContent UpdateTaskIsBack(int taskNum, int Inflag) + { + WebResponseContent content = new WebResponseContent(); + try + { + Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); + if (task == null) return WebResponseContent.Instance.Error($"鏈壘鍒拌浠诲姟淇℃伅,浠诲姟鍙�:銆恵taskNum}銆�"); + task.Remark = Inflag.ToString(); + task.ModifyDate = DateTime.Now; + BaseDal.UpdateData(task); + } + catch (Exception ex) + { + content = WebResponseContent.Instance.Error(ex.Message); + } + return content; + + } + + /// <summary> /// 鏇存柊浠诲姟鐘舵�佷俊鎭紝骞跺悓姝ヨ嚦WMS /// </summary> /// <param name="taskId">浠诲姟ID</param> @@ -749,7 +1072,7 @@ { if (task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting) { - + if (task.TaskType == (int)TaskOutboundTypeEnum.OutInventory || task.TaskType == (int)TaskOutboundTypeEnum.OutPick)//寮傚父鍑哄簱 绌鸿溅鍑哄簱 { task.TaskState = (int)TaskOutStatusEnum.OutFinish; @@ -784,8 +1107,14 @@ } - else + else//涓婃枡浠诲姟涔熸敼涓哄己鍒跺畬鎴�20250115 { + //鏇存柊鐘舵�佷负浠诲姟瀹屾垚 + //task.TaskState = (int)TaskOutStatusEnum.OutFinish; + //UpdateTaskStatus(task.TaskId, task.TaskState); + //_taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撳畬鎴�"); + //_taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍑哄簱浠诲姟瀹屾垚"); + //isBack = true; return WebResponseContent.Instance.Error($"涓婃枡浠诲姟涓嶅厑璁″己鍒跺畬鎴愶紒"); } } @@ -826,6 +1155,26 @@ } /// <summary> + /// 鍏佽閲嶇疆 + /// </summary> + /// <param name="taskNum"></param> + /// <returns></returns> + public WebResponseContent AGVResetTask() + { + WebResponseContent content = new WebResponseContent(); + Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == "1"); + if (task != null) + { + UpdateTaskAllowIn(task.TaskNum, 0); + } + else + { + return WebResponseContent.Instance.Error($"鐩墠鏄厑璁GV杩涘叆鐘舵�侊紝鏃犻渶閲嶇疆锛�"); + } + return content.Error("閲嶇疆鎴愬姛锛�"); + } + + /// <summary> /// 浠诲姟鍙栨秷 /// </summary> /// <param name="taskid"></param> @@ -838,6 +1187,12 @@ //1锛屽厛鏌ヨ浠诲姟锛屾牴鎹笉鍚岀殑浠诲姟绫诲瀷鍋氫换鍔″彇娑堟搷浣� Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum); if (task == null) return WebResponseContent.Instance.Error($"鏈壘鍒拌浠诲姟淇℃伅,浠诲姟鍙�:銆恵taskNum}銆�"); + + //鍙栨秷浠诲姟鏃讹紝閲嶇疆鏄惁鍏佽杩涘叆 + if (task.CurrentAddress == "1") + { + UpdateTaskAllowIn(task.TaskNum, 0); + } Dt_LocationInfo locationsrc = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress.ToString()); Dt_LocationInfo locationdsc = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress.ToString()); @@ -1127,12 +1482,15 @@ } else { - MESSendCMD sendcmd = new MESSendCMD { cmd = 201, task_id = task.TaskNum, status = 6 }; - MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); - if (res != null && res.code != 0) + if (task.WMSId != 3) { - ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚寮傚父鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); - content = WebResponseContent.Instance.Error($"澶у爢鍨涙満瀹屾垚寮傚父鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); + MESSendCMD sendcmd = new MESSendCMD { cmd = 201, task_id = task.TaskNum, status = 6 }; + MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); + if (res != null && res.code != 0) + { + ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚寮傚父鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); + content = WebResponseContent.Instance.Error($"澶у爢鍨涙満瀹屾垚寮傚父鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); + } } } @@ -1140,7 +1498,7 @@ catch (Exception ex) { _unitOfWorkManage.RollbackTran(); - //浠诲姟鎵ц澶辫触锛岃揣浣嶇姸鎬佽繕鍘� + ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�"); content = WebResponseContent.Instance.Error($"澶у爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�"); } @@ -1173,16 +1531,19 @@ MESSendCMD sendcmd = new MESSendCMD { cmd = 201, task_id = int.Parse(task.NextAddress), status = 6 }; string inparam = JsonConvert.SerializeObject(sendcmd); ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚鍏ュ簱浠诲姟鍚庡洖浼燤ES鍏ュ弬:{inparam}"); - MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); - if (res != null && res.code != 0) + if (task.WMSId != 3) { + MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); + if (res != null && res.code != 0) + { - ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚鍏ュ簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); - content = WebResponseContent.Instance.Error($"澶у爢鍨涙満瀹屾垚鍏ュ簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); - } - else - { - ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚鍏ュ簱浠诲姟鍚庡洖浼燤ES鎴愬姛锛�,浠诲姟鍙�:銆恵taskNum}銆�"); + ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚鍏ュ簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); + content = WebResponseContent.Instance.Error($"澶у爢鍨涙満瀹屾垚鍏ュ簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); + } + else + { + ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚鍏ュ簱浠诲姟鍚庡洖浼燤ES鎴愬姛锛�,浠诲姟鍙�:銆恵taskNum}銆�"); + } } } @@ -1216,15 +1577,36 @@ _unitOfWorkManage.CommitTran(); //绉诲簱瀹屾垚锛屽洖浼燤ES //鍥炰紶鍒癢MS - MESSendCMD sendcmd = new MESSendCMD { cmd = 201, task_id = task.TaskNum, status = 6 }; - string inparam = JsonConvert.SerializeObject(sendcmd); - ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚鍑哄簱浠诲姟鍚庡洖浼燤ES鍏ュ弬:{inparam}"); - MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); - if (res != null && res.code != 0) + if (task.WMSId != 3) { - ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); - content = WebResponseContent.Instance.Error($"澶у爢鍨涙満瀹屾垚鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); + MESSendCMD sendcmd = new MESSendCMD { cmd = 201, task_id = task.TaskNum, status = 6 }; + string inparam = JsonConvert.SerializeObject(sendcmd); + ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚鍑哄簱浠诲姟鍚庡洖浼燤ES鍏ュ弬:{inparam}"); + MESResponse res = ApiInvoke.SendTaskCMD(sendcmd); + if (res != null && res.code != 0) + { + ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満瀹屾垚鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); + content = WebResponseContent.Instance.Error($"澶у爢鍨涙満瀹屾垚鍑哄簱浠诲姟鍚庡洖浼燤ES澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵res.message}銆�"); + } } + //if(task.TaskType== (int)TaskRelocationTypeEnum.Relocation&&!string.IsNullOrEmpty(task.Remark.Trim()))//鍑哄簱浠诲姟鍐欐�诲眰鏁版爣璇� + //{ + // CommonStackerCrane commonStackerCrane = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC01") as CommonStackerCrane; + // //鏍规嵁浠诲姟婧愬湴鍧�纭畾鍐欏叆PLC浣嶇疆 Depth + // Dt_LocationInfo location = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress); + // if (commonStackerCrane!=null&&location != null) + // { + // bool issuccess = commonStackerCrane.Communicator.Write<short>("DB28." + location.Depth + ".0", 9); + // if (issuccess) + // { + // ServiceLogger.WriteDebug("TaskService", $"鍘熸枡鍑哄簱鍚庡啓鍏ユ爣璇嗘垚鍔燂紒"); + // } + // else + // { + // ServiceLogger.WriteDebug("TaskService", $"鍘熸枡鍑哄簱鍚庡啓鍏ユ爣璇嗗け璐ワ紒"); + // } + // } + //} } catch (Exception ex) -- Gitblit v1.9.3