From 3d07ccb8342a92b32bc8858ecf56d257d6b500c9 Mon Sep 17 00:00:00 2001 From: duyongjia <adu_555@163.com> Date: 星期三, 27 十一月 2024 16:38:55 +0800 Subject: [PATCH] 前端增加任务取消按钮 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 143 ++++++++++++++++++++++++++++++++++++----------- 1 files changed, 109 insertions(+), 34 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 a9fbbb3..dec3bb8 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" @@ -54,6 +54,7 @@ private readonly ILocationInfoRepository _locationInfoRepository; private readonly IMapper _mapper; private readonly IUnitOfWorkManage _unitOfWorkManage; + private readonly ITaskRepository _taskRepository; private Dictionary<string, OrderByType> _taskOrderBy = new() { @@ -71,7 +72,7 @@ public List<int> TaskOtherboundTypes => typeof(TaskOtherTypeEnum).GetEnumIndexList(); - public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ILocationInfoRepository locationInfoRepository, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) + public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ILocationInfoRepository locationInfoRepository, IUnitOfWorkManage unitOfWorkManage, ITaskRepository taskRepository) : base(BaseDal) { _routerService = routerService; _taskExecuteDetailService = taskExecuteDetailService; @@ -79,6 +80,7 @@ _mapper = mapper; _locationInfoRepository = locationInfoRepository; _unitOfWorkManage = unitOfWorkManage; + _taskRepository = taskRepository; } /// <summary> @@ -183,7 +185,7 @@ return content = WebResponseContent.Instance.Error($"WCS鏈煡璇㈠埌婧愮珯鐐瑰搴旂殑搴撲綅锛屾簮绔欑偣锛歿taskDTO.dest_station.ToString()}"); } break; - case 3001://AGV鏀捐揣瀹屾垚 WMS鍙�3001鐨勫悓鏃朵細鍐欐彁鍗囦俊鍙� + case 3001://AGV鏀捐揣瀹屾垚 WMS鍙�3001鐨勫悓鏃禬CS闇�鍦╦ob涓啓鎻愬崌淇″彿 if (BaseDal.QueryFirst(x => x.TaskNum == taskDTO.task_id) == null)//鎵嬪姩鍏ュ簱鐩存帴鍙�3001锛岄渶瑕佺敓鎴愪换鍔★紝鍥犱负娌℃湁1001鐜妭 { @@ -468,7 +470,7 @@ } catch (Exception ex) { - ServiceLogger.WriteDebug("ReceiveTask", $"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}"); + ServiceLogger.WriteDebug("ReceiveTask", $"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.StackTrace}"); content = WebResponseContent.Instance.Error($"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}"); } return content; @@ -678,7 +680,7 @@ _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, task.ExceptionMessage); - content = WebResponseContent.Instance.OK(); + } catch (Exception ex) { @@ -700,6 +702,75 @@ task.Modifier = "System"; task.ModifyDate = DateTime.Now; BaseDal.UpdateData(task); + } + + /// <summary> + /// 浠诲姟寮哄埗瀹屾垚 + /// </summary> + /// <param name="taskNum"></param> + /// <returns></returns> + public WebResponseContent ForceCompleteTask(int taskNum) + { + return null; + + } + + /// <summary> + /// 浠诲姟鍙栨秷 + /// </summary> + /// <param name="taskid"></param> + /// <returns></returns> + public WebResponseContent CancelTask(int taskid) + { + WebResponseContent content = new WebResponseContent(); + try + { + //鍏堟煡璇换鍔★紝鏍规嵁涓嶅悓鐨勪换鍔$被鍨嬪仛浠诲姟鍙栨秷鎿嶄綔 + bool isAllow = false; + Dt_Task task = _taskRepository.QueryFirst(x => x.TaskId == taskid); + if (task == null) return WebResponseContent.Instance.Error($"鏈壘鍒拌浠诲姟淇℃伅,浠诲姟id:銆恵taskid}銆�"); + + //濡傛灉鏄叆搴撳垎鑷姩鍜屾墜鍔ㄤ袱绉嶆儏鍐靛鐞� + if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) + { + if (task.WMSId == 0 && task.TaskState == (int)TaskInStatusEnum.InNew)//鑷姩鍏ュ簱锛�1001-AGV璇锋眰鏄惁鍏佽杩涘叆锛屼换鍔$姸鎬佷负鈥滄柊寤哄叆搴撲换鍔�200鈥濅箣鍓嶅彲浠ュ彇娑� + { + isAllow = true; + task.TaskState = (int)TaskInStatusEnum.InCancel; + } + else if (task.WMSId == 1 && task.TaskState == (int)TaskInStatusEnum.AGV_InExecuting)//鎵嬪姩鍏ュ簱锛�3001-AGV鏀捐揣瀹屾垚锛屼换鍔$姸鎬佷负鈥淎GV鍏ュ簱鎵ц涓�210鈥濅箣鍓嶅彲浠ュ彇娑� + { + isAllow = true; + task.TaskState = (int)TaskInStatusEnum.InCancel; + } + } + else//鍏朵粬浠诲姟锛屼换鍔$姸鎬佲�滄柊寤哄嚭搴撲换鍔♀�濅箣鍓嶏紝鎵嶅彲浠ュ彇娑� + { + if (task.TaskState == (int)TaskOutStatusEnum.OutNew) + { + isAllow = true; + task.TaskState = (int)TaskOutStatusEnum.OutCancel; + } + } + + if (isAllow)//濡傛灉鍏佽鍙栨秷 + { + //鏇存柊鐘舵�佷负浠诲姟鍙栨秷 + UpdateTaskStatus(task.TaskId, task.TaskState); + _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鎵嬪姩浠诲姟鍙栨秷"); + content = WebResponseContent.Instance.OK("鍙栨秷鎴愬姛锛�"); + //鍚屾鍥炰紶WMS + } + else + { + content = WebResponseContent.Instance.OK("璇ヤ换鍔$洰鍓嶇姸鎬佷笉鍏呰鍙栨秷锛�"); + } + } + catch (Exception ex) + { + content = WebResponseContent.Instance.Error(ex.Message); + } + return content; } @@ -884,6 +955,7 @@ catch (Exception ex) { _unitOfWorkManage.RollbackTran(); + //浠诲姟鎵ц澶辫触锛岃揣浣嶇姸鎬佽繕鍘� ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"澶у爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�"); content = WebResponseContent.Instance.Error($"澶у爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�"); } @@ -982,7 +1054,7 @@ { try { - Dt_LocationInfo srcLocation = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); + //Dt_LocationInfo srcLocation = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); //srcLocation.LocationStatus = (int)LocationStatusEnum.Free; @@ -1002,44 +1074,45 @@ 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 - { - //鍒ゆ柇鏄惁瀹屾垚鐨勬渶鍚庝竴灞傦紝鑷姩鐢熸垚绌鸿溅鍑哄簱浠诲姟 - string[] Levels = task.Remark.Split("-"); - if (Levels.Length == 2) - { - if (!string.IsNullOrEmpty(Levels[0])&& !string.IsNullOrEmpty(Levels[1])) - { - //濡傛灉褰撳墠鎻愬彇灞傛暟绛変簬鎬诲眰鏂欙紝鍒欒〃绀烘枡杞︽墍鏈夌殑灞傛暟鍙栧畬 - if(Convert.ToInt16(Levels[0])== Convert.ToInt16(Levels[1])) - { - string[] SourceCodes = task.SourceAddress.Split("-"); - string startPlan = ""; - if (SourceCodes.Length == 4) - { - startPlan= "101"+ SourceCodes[2].Substring(1,2); - } - DeliveryPlan send = new DeliveryPlan { startPlan = startPlan, isQuit = false, CarId = task.PalletCode }; - string inparam2 = JsonConvert.SerializeObject(send); - ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟鍥炰紶MES鍏ュ弬{inparam2}"); - ApiInvoke.DeliveryPlanCMD(send);//鍥炶皟MES鎺ュ彛鐢熸垚绌鸿溅鍑哄簱浠诲姟 - //鎵�鏈夌殑灞傛暟閮藉彇瀹岋紝闇�瑕佹妸鏆傚瓨浣嶇姸鎬佹敼涓虹┖闂茬姸鎬� - srcLocation.LocationStatus = (int)LocationStatusEnum.Free; - _locationInfoRepository.UpdateData(srcLocation); - } + //else + //{ + // //鍒ゆ柇鏄惁瀹屾垚鐨勬渶鍚庝竴灞傦紝鑷姩鐢熸垚绌鸿溅鍑哄簱浠诲姟 + // string[] Levels = task.Remark.Split("-"); + // if (Levels.Length == 2) + // { + // if (!string.IsNullOrEmpty(Levels[0])&& !string.IsNullOrEmpty(Levels[1])) + // { + // //濡傛灉褰撳墠鎻愬彇灞傛暟绛変簬鎬诲眰鏂欙紝鍒欒〃绀烘枡杞︽墍鏈夌殑灞傛暟鍙栧畬 + // if(Convert.ToInt16(Levels[0])== Convert.ToInt16(Levels[1])) + // { + // string[] SourceCodes = task.SourceAddress.Split("-"); + // string startPlan = ""; + // if (SourceCodes.Length == 4) + // { + // startPlan = "101" + SourceCodes[2].Substring(1, 2); + // } + // DeliveryPlan send = new DeliveryPlan { startPlan = startPlan, isQuit = false, CarId = task.PalletCode }; + // string inparam2 = JsonConvert.SerializeObject(send); + // ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟鍥炰紶MES鍏ュ弬{inparam2}"); + // ApiInvoke.DeliveryPlanCMD(send);//鍥炶皟MES鎺ュ彛鐢熸垚绌鸿溅鍑哄簱浠诲姟 + // 鎵�鏈夌殑灞傛暟閮藉彇瀹岋紝闇�瑕佹妸鏆傚瓨浣嶇姸鎬佹敼涓虹┖闂茬姸鎬� + // srcLocation.LocationStatus = (int)LocationStatusEnum.Free; + // _locationInfoRepository.UpdateData(srcLocation); + // } - } + // } - } - } + // } + //} } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); - ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�"); + ServiceLogger.WriteDebug("StackCraneTaskCompleted", $"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.StackTrace}銆�"); content = WebResponseContent.Instance.Error($"灏忓爢鍨涙満鎵ц鍑哄簱浠诲姟澶辫触锛�,浠诲姟鍙�:銆恵taskNum}銆�,澶辫触淇℃伅:銆恵ex.Message}銆�"); } @@ -1060,6 +1133,8 @@ return content; } + + /// <summary> /// 鎭㈠鎸傝捣浠诲姟 /// </summary> -- Gitblit v1.9.3