From eee43c4cb7f9018688cd6da6a3611512f3e5c5c3 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期六, 28 十二月 2024 09:18:06 +0800 Subject: [PATCH] 1 --- 代码管理/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/e75f7da2-6ce6-4dbf-9778-711f44383902.vsidx | 0 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/InitializationLocationDTO.cs | 2 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/测试架仓/GroundStationJob_CSJ.cs | 92 ++++++-- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskEnumHelper.cs | 4 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/PermissionDataHostService.cs | 37 +- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs | 2 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs | 23 ++ 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/油墨仓/StackerCraneJob_YM.cs | 129 ++++++---- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs | 29 ++ 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskEnumHelper.cs | 20 + 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 3 /dev/null | 0 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs | 3 代码管理/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/4c556b7e-ac07-429f-bc24-3cd592323521.vsidx | 0 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs | 9 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/油墨仓/CommonHoisterJob.cs | 10 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/测试架仓/StackerCraneJob_CSJ.cs | 115 +++++----- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs | 4 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 44 +++ 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs | 80 +++++- 20 files changed, 418 insertions(+), 188 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/e75f7da2-6ce6-4dbf-9778-711f44383902.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/e75f7da2-6ce6-4dbf-9778-711f44383902.vsidx" new file mode 100644 index 0000000..b616cac --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/e75f7da2-6ce6-4dbf-9778-711f44383902.vsidx" Binary files differ diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/read.lock" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/read.lock" deleted file mode 100644 index e69de29..0000000 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/FileContentIndex/read.lock" +++ /dev/null diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskEnumHelper.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskEnumHelper.cs" index 004a523..760da8e 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskEnumHelper.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskEnumHelper.cs" @@ -20,11 +20,11 @@ { if (taskType >= 500 && taskType < 900) { - return TaskTypeGroup.OutbondGroup; + return TaskTypeGroup.InboundGroup; } else if (taskType >= 100 && taskType < 500) { - return TaskTypeGroup.InboundGroup; + return TaskTypeGroup.OutbondGroup; } else if (taskType >= 900 && taskType < 1000) { diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs" index 0fa1d52..102fe3a 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs" @@ -72,6 +72,8 @@ /// <returns></returns> string? RequestAssignLocation(int taskNum, string roadwayNo); + WebResponseContent TaskCompleted(int taskNum); + /// <summary> /// 鏍规嵁璁惧缂栧彿銆佷换鍔$被鍨嬪垎缁�(鍙��)鎸夌収浼樺厛绾т互鍙婂垱寤烘椂闂存帓搴忔煡璇换鍔℃睜鏂板鐨勪换鍔� /// </summary> 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 35f3322..3ab0634 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" @@ -27,6 +27,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; +using WIDESEAWCS_Common.APIEnum; using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Core; using WIDESEAWCS_Core.BaseServices; @@ -38,6 +39,7 @@ using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; +using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.Models; using WIDESEAWCS_QuartzJob.Repository; using WIDESEAWCS_QuartzJob.Service; @@ -54,6 +56,7 @@ private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository; private readonly IStationMangerRepository _stationMangerRepository; private readonly IRouterRepository _routerRepository; + private List<Dt_ApiInfo> apiInfos; private Dictionary<string, OrderByType> _taskOrderBy = new() { @@ -65,9 +68,9 @@ public Dictionary<string, OrderByType> TaskOrderBy { get { return _taskOrderBy; } set { _taskOrderBy = value; } } - public List<int> TaskInboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 100 && x < 500).ToList(); + public List<int> TaskInboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 500 && x < 900).ToList(); - public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 500 && x < 900).ToList(); + public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 100 && x < 500).ToList(); public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository) : base(BaseDal) { @@ -85,6 +88,21 @@ Warehouses = JsonConvert.DeserializeObject<List<Dt_Warehouse>>(cacheStr); } + + string? apiInfoStr = _cacheService.Get("apiInfos"); + if (!string.IsNullOrEmpty(apiInfoStr)) + { + List<Dt_ApiInfo>? infos = JsonConvert.DeserializeObject<List<Dt_ApiInfo>>(apiInfoStr); + if (infos == null || infos.Count == 0) + { + apiInfos = new List<Dt_ApiInfo>(); + } + else + { + apiInfos = infos; + } + } + } public WebResponseContent TaskCompleted(int taskNum) @@ -94,10 +112,18 @@ Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); if (task != null) { - + BaseDal.DeleteAndMoveIntoHty(task, App.User == null ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚); } - - return WebResponseContent.Instance.OK(); + string? url = apiInfos.FirstOrDefault(x => x.ApiCode == APIEnum.FeedBackWMSTaskCompleted.ToString())?.ApiAddress; + if (string.IsNullOrEmpty(url)) + { + _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"鏈壘鍒癢MS浠诲姟瀹屾垚鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�"); + UpdateTaskExceptionMessage(taskNum, $"鏈壘鍒癢MS浠诲姟瀹屾垚鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�"); + return WebResponseContent.Instance.Error($"{taskNum},鏈壘鍒癢MS浠诲姟瀹屾垚鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�"); + } + string responseStr = HttpHelper.Get(url + "?taskNum=" + taskNum); + WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(responseStr) ?? WebResponseContent.Instance.Error($"{taskNum},鏈帴鏀跺埌浠诲姟瀹屾垚杩斿洖鍊�"); + return content; } catch (Exception ex) { @@ -141,7 +167,7 @@ return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃俊鎭�"); } - List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && (stationManger.StationDeviceCode == x.StartPosi || stationManger.StackerCraneCode == x.StartPosi)); + List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && (stationManger.StationCode == x.StartPosi || stationManger.StackerCraneCode == x.StartPosi)); if (routers.FirstOrDefault() == null) { return WebResponseContent.Instance.Error($"鏈壘鍒拌矾鐢遍厤缃俊鎭�"); @@ -150,6 +176,10 @@ if (routers.Count == 1) { task.NextAddress = router?.NextPosi ?? ""; + } + else + { + task.NextAddress = ""; } } else @@ -254,7 +284,7 @@ public Dt_Task QueryStackerCraneTask(string deviceNo, string currentAddress = "") { if (string.IsNullOrEmpty(currentAddress)) - return BaseDal.QueryFirst(x => x.DeviceCode == deviceNo && x.TaskState == (int)TaskStatusEnum.New, TaskOrderBy); + return BaseDal.QueryFirst(x => x.DeviceCode == deviceNo && x.TaskState == (int)TaskStatusEnum.SC_Execute, TaskOrderBy); else return BaseDal.QueryFirst(x => x.DeviceCode == deviceNo && x.CurrentAddress == currentAddress && x.TaskState == (int)TaskStatusEnum.SC_Execute, TaskOrderBy); } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\262\271\345\242\250\344\273\223/CommonHoisterJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\262\271\345\242\250\344\273\223/CommonHoisterJob.cs" index 62c0a55..1be248c 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\262\271\345\242\250\344\273\223/CommonHoisterJob.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\262\271\345\242\250\344\273\223/CommonHoisterJob.cs" @@ -76,7 +76,7 @@ Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && x.SourceAddress == deviceChildCode && _taskService.TaskInboundTypes.Contains(x.TaskType)); if (task != null) { - Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationDeviceCode == deviceChildCode); + Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == deviceChildCode); if (stationManger == null) { WriteInfo(hoister.DeviceName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{deviceChildCode},浠诲姟鍙�:{task.TaskNum}"); @@ -88,7 +88,7 @@ WriteInfo(hoister.DeviceName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{deviceChildCode},浠诲姟鍙�:{task.TaskNum}"); break; } - + task.CurrentAddress = stationManger.StackerCraneStationCode; task.TargetAddress = locationCode; task.NextAddress = locationCode; task.DeviceCode = stationManger.StackerCraneCode; @@ -99,7 +99,7 @@ } else { - WriteInfo(hoister.DeviceName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,{deviceChildCode}"); + WriteInfo(hoister.DeviceName, $"鏈壘鍒板搴斾换鍔′俊鎭�,{deviceChildCode}"); } } else if (leisure && !tray && !requestIn && !inbounding && !requestOut && !outbounding) @@ -116,7 +116,7 @@ Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && _taskService.TaskOutboundTypes.Contains(x.TaskType)); if (task != null) { - Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationDeviceCode == deviceChildCode); + Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == deviceChildCode); if (stationManger == null) { WriteInfo(hoister.DeviceName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{deviceChildCode},浠诲姟鍙�:{task.TaskNum}"); @@ -124,7 +124,7 @@ } task.TargetAddress = deviceChildCode; - task.NextAddress = deviceChildCode; + task.NextAddress = stationManger.StackerCraneStationCode; ; task.DeviceCode = stationManger.StackerCraneCode; task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); _taskRepository.UpdateData(task); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\262\271\345\242\250\344\273\223/StackerCraneJob_YM.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\262\271\345\242\250\344\273\223/StackerCraneJob_YM.cs" index 61684c3..1e8b0df 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\262\271\345\242\250\344\273\223/StackerCraneJob_YM.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\262\271\345\242\250\344\273\223/StackerCraneJob_YM.cs" @@ -87,6 +87,7 @@ commonStackerCrane.LastTaskType = task.TaskType; int oldState = task.TaskState; task.TaskState = TaskStatusEnum.SC_Executing.ObjToInt(); + task.ExceptionMessage = ""; _taskRepository.UpdateData(task); _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"绯荤粺鑷姩娴佺▼锛屼换鍔$姸鎬佷粠銆恵oldState}銆戣浆鍒般�恵task.TaskState}銆�"); } @@ -110,32 +111,30 @@ private void CommonStackerCrane_StackerCraneTaskCompletedEventHandler(object? sender, WIDESEAWCS_QuartzJob.StackerCrane.StackerCraneTaskCompletedEventArgs e) { CommonStackerCrane? commonStackerCrane = sender as CommonStackerCrane; - if (commonStackerCrane != null) + try { - WriteInfo(commonStackerCrane.DeviceName, $"璇诲彇鍒颁换鍔″畬鎴愪俊鍙�,{e.TaskNum}"); - if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) + if (commonStackerCrane != null) { - Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum); - if (task != null) + WriteInfo(commonStackerCrane.DeviceName, $"璇诲彇鍒颁换鍔″畬鎴愪俊鍙�,{e.TaskNum}"); + if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) { - string? url = apiInfos.FirstOrDefault(x => x.ApiCode == APIEnum.FeedBackWMSTaskCompleted.ToString())?.ApiAddress; - if (string.IsNullOrEmpty(url)) + Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum); + if (task != null) { - _taskExecuteDetailService.AddTaskExecuteDetail(e.TaskNum, $"鏈壘鍒板洖璋僕MS浠诲姟瀹屾垚鎺ュ彛"); - WriteInfo(commonStackerCrane.DeviceName, $"鏈壘鍒板洖璋僕MS浠诲姟瀹屾垚鎺ュ彛"); - return; + _taskService.TaskCompleted(e.TaskNum); } - - HttpHelper.Post($"{url}?taskNum={e.TaskNum}", "");//todo 璋冪敤WMS浠诲姟瀹屾垚鏂规硶 - _taskExecuteDetailService.AddTaskExecuteDetail(e.TaskNum, $"绯荤粺鑷姩娴佺▼,浠诲姟瀹屾垚"); - _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚); + else + { + WriteInfo(commonStackerCrane.DeviceName, $"璇诲彇鍒颁换鍔″畬鎴愪俊鍙�,鏈壘鍒板搴旂殑浠诲姟淇℃伅,{e.TaskNum}"); + } + commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); } - else - { - WriteInfo(commonStackerCrane.DeviceName, $"璇诲彇鍒颁换鍔″畬鎴愪俊鍙�,鏈壘鍒板搴旂殑浠诲姟淇℃伅,{e.TaskNum}"); - } - commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); } + } + catch (Exception ex) + { + WriteError(commonStackerCrane?.DeviceCode ?? nameof(StackerCraneJob_YM), ex.Message, ex); + } } @@ -245,22 +244,31 @@ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔� { string[] startCodes = task.CurrentAddress.Split("-"); - - stackerCraneTaskCommand.StartRow = Convert.ToInt16(startCodes[0]); - stackerCraneTaskCommand.StartColumn = Convert.ToInt16(startCodes[1]); - stackerCraneTaskCommand.StartLayer = Convert.ToInt16(startCodes[2]); + if (startCodes.Length == 3) + { + stackerCraneTaskCommand.StartRow = Convert.ToInt16(startCodes[0]); + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(startCodes[1]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(startCodes[2]); + } + else + { + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); + WriteInfo(task.DeviceCode, $"鍏ュ簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); + return null; + } string[] targetCodes = task.NextAddress.Split("-"); - if (targetCodes.Length == 3) + if (targetCodes.Length == 5) { - stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); - stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); - stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); + stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); + stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); + stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]); } else { //鏁版嵁閰嶇疆閿欒 - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); + WriteInfo(task.DeviceCode, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); return null; } } @@ -268,27 +276,6 @@ { string[] targetCodes = task.NextAddress.Split("-"); - stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); - stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); - stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); - - string[] sourceCodes = task.CurrentAddress.Split("-"); - if (sourceCodes.Length == 3) - { - stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); - stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); - stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); - } - else - { - //鏁版嵁閰嶇疆閿欒 - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); - return null; - } - } - else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) - { - string[] targetCodes = task.NextAddress.Split("-"); if (targetCodes.Length == 3) { stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); @@ -298,20 +285,54 @@ else { //鏁版嵁閰嶇疆閿欒 - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); + WriteInfo(task.DeviceCode, $"鍑哄簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); + return null; + } + + string[] sourceCodes = task.CurrentAddress.Split("-"); + if (sourceCodes.Length == 5) + { + stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]); + } + else + { + //鏁版嵁閰嶇疆閿欒 + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); + WriteInfo(task.DeviceCode, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); + return null; + } + } + else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) + { + string[] targetCodes = task.NextAddress.Split("-"); + if (targetCodes.Length == 5) + { + stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); + stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); + stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]); + } + else + { + //鏁版嵁閰嶇疆閿欒 + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); + WriteInfo(task.DeviceCode, $"绉诲簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); return null; } string[] sourceCodes = task.CurrentAddress.Split("-"); - if (sourceCodes.Length == 3) + if (sourceCodes.Length == 5) { - stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); - stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); - stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]); } else { //鏁版嵁閰嶇疆閿欒 _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); + WriteInfo(task.DeviceCode, $"绉诲簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); return null; } } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/GroundStationJob_CSJ.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/GroundStationJob_CSJ.cs" index 023c6cd..80a52fe 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/GroundStationJob_CSJ.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/GroundStationJob_CSJ.cs" @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Common; @@ -12,6 +13,7 @@ using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; +using WIDESEAWCS_Tasks.HoisterJob; namespace WIDESEAWCS_Tasks { @@ -44,43 +46,83 @@ WriteInfo(nameof(GroundStationJob_CSJ), "璋冨害閿欒,璁惧瀵硅薄浼犲�间负null"); return Task.CompletedTask; } - + List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList(); List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode); - foreach (var item in stationMangers) + foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode))) { - bool isCanPut = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, item.StationCode); - bool isCanTake = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, item.StationCode); - bool putRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutRequest, item.StationCode); - bool putFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutFinish, item.StationCode); - bool takeRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeRequest, item.StationCode); - bool takeFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeFinish, item.StationCode); - - if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) + try { - Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); - if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) + bool isCanPut = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, item.StationCode); + bool isCanTake = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, item.StationCode); + bool putRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutRequest, item.StationCode); + bool putFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutFinish, item.StationCode); + bool takeRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeRequest, item.StationCode); + bool takeFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeFinish, item.StationCode); + + if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) { - string oldAddress = task.NextAddress; - int oldStatus = task.TaskState; - task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); - task.NextAddress = item.StationCode; - _taskRepository.UpdateData(task); - _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绯荤粺鑷姩娴佺▼,鐩爣鍦板潃鐢眥oldAddress}鍙樻洿涓簕task.NextAddress},浠诲姟鐘舵�佺敱{oldStatus}鍙樻洿涓簕task.TaskState}"); + Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); + if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) + { + string oldAddress = task.NextAddress; + int oldStatus = task.TaskState; + task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); + task.NextAddress = item.StationCode; + _taskRepository.UpdateData(task); + _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绯荤粺鑷姩娴佺▼,鐩爣鍦板潃鐢眥oldAddress}鍙樻洿涓簕task.NextAddress},浠诲姟鐘舵�佺敱{oldStatus}鍙樻洿涓簕task.TaskState}"); + } + } + if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) + { + Dt_Task task = _taskRepository.QueryFirst(x => x.TargetAddress == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); + if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) + { + string oldAddress = task.NextAddress; + int oldStatus = task.TaskState; + task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); + task.NextAddress = item.StationCode; + _taskRepository.UpdateData(task); + _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绯荤粺鑷姩娴佺▼,鐩爣鍦板潃鐢眥oldAddress}鍙樻洿涓簕task.NextAddress},浠诲姟鐘舵�佺敱{oldStatus}鍙樻洿涓簕task.TaskState}"); + } } } - else if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) + catch (Exception ex) { - Dt_Task task = _taskRepository.QueryFirst(x => x.TargetAddress == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); - if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) + WriteError(device.DeviceCode, $"{item}浜や簰閿欒", ex); + } + } + + foreach (var item in stationMangers.Where(x => !deviceStations.Contains(x.StationCode))) + { + try + { + Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && x.SourceAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType)); + if (task != null) { - string oldAddress = task.NextAddress; - int oldStatus = task.TaskState; + Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode); + if (stationManger == null) + { + WriteInfo(item.StationName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + break; + } + string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode); + if (string.IsNullOrEmpty(locationCode)) + { + WriteInfo(item.StationName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + break; + } + task.CurrentAddress = stationManger.StackerCraneStationCode; + task.TargetAddress = locationCode; + task.NextAddress = locationCode; + task.DeviceCode = stationManger.StackerCraneCode; task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); - task.NextAddress = item.StationCode; _taskRepository.UpdateData(task); - _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绯荤粺鑷姩娴佺▼,鐩爣鍦板潃鐢眥oldAddress}鍙樻洿涓簕task.NextAddress},浠诲姟鐘舵�佺敱{oldStatus}鍙樻洿涓簕task.TaskState}"); } } + catch(Exception ex) + { + + } } } catch (Exception ex) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/StackerCraneJob_CSJ.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/StackerCraneJob_CSJ.cs" index 2911a93..3cd1f34 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/StackerCraneJob_CSJ.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/StackerCraneJob_CSJ.cs" @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Common.APIEnum; @@ -73,28 +74,23 @@ { commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 } - - if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal) + commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� + if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) { - commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� - - if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) + Dt_Task? task = GetTask(commonStackerCrane); + if (task != null) { - Dt_Task? task = GetTask(commonStackerCrane); - if (task != null) + StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); + if (stackerCraneTaskCommand != null) { - StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); - if (stackerCraneTaskCommand != null) + bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); + if (sendFlag) { - bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); - if (sendFlag) - { - commonStackerCrane.LastTaskType = task.TaskType; - int oldState = task.TaskState; - task.TaskState = TaskStatusEnum.SC_Executing.ObjToInt(); - _taskRepository.UpdateData(task); - _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"绯荤粺鑷姩娴佺▼锛屼换鍔$姸鎬佷粠銆恵oldState}銆戣浆鍒般�恵task.TaskState}銆�"); - } + commonStackerCrane.LastTaskType = task.TaskType; + int oldState = task.TaskState; + task.TaskState = TaskStatusEnum.SC_Executing.ObjToInt(); + _taskRepository.UpdateData(task); + _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"绯荤粺鑷姩娴佺▼锛屼换鍔$姸鎬佷粠銆恵oldState}銆戣浆鍒般�恵task.TaskState}銆�"); } } } @@ -120,7 +116,6 @@ { if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) { - Console.Out.WriteLine("TaskCompleted" + e.TaskNum); StackerCraneTaskCompleted(e.TaskNum, commonStackerCrane.DeviceCode); commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); } @@ -144,19 +139,9 @@ _taskRepository.UpdateData(task); _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"绯荤粺鑷姩娴佺▼,锛屼换鍔$姸鎬佷粠銆恵oldStatus}銆戣浆鍒般�恵task.TaskState}銆�"); } - else if (task.TaskType.GetTaskTypeGroup() != TaskTypeGroup.InboundGroup || task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) + else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup || task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) { - string? url = apiInfos.FirstOrDefault(x => x.ApiCode == APIEnum.FeedBackWMSTaskCompleted.ToString())?.ApiAddress; - if (string.IsNullOrEmpty(url)) - { - _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"鏈壘鍒板洖璋僕MS浠诲姟瀹屾垚鎺ュ彛"); - WriteInfo(deviceCode, $"鏈壘鍒板洖璋僕MS浠诲姟瀹屾垚鎺ュ彛"); - return WebResponseContent.Instance.Error(); - } - - HttpHelper.Post($"{url}?taskNum={taskNum}", "");//todo 璋冪敤WMS浠诲姟瀹屾垚鏂规硶 - _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"绯荤粺鑷姩娴佺▼,浠诲姟瀹屾垚"); - _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚); + _taskService.TaskCompleted(taskNum); } else { @@ -302,13 +287,39 @@ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔� { string[] startCodes = task.CurrentAddress.Split("-"); - - stackerCraneTaskCommand.StartRow = Convert.ToInt16(startCodes[0]); - stackerCraneTaskCommand.StartColumn = Convert.ToInt16(startCodes[1]); - stackerCraneTaskCommand.StartLayer = Convert.ToInt16(startCodes[2]); + if (startCodes.Length == 3) + { + stackerCraneTaskCommand.StartRow = Convert.ToInt16(startCodes[0]); + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(startCodes[1]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(startCodes[2]); + } + else + { + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); + WriteInfo(task.DeviceCode, $"鍏ュ簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); + return null; + } string[] targetCodes = task.NextAddress.Split("-"); if (targetCodes.Length == 5) + { + stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); + stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); + stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]); + } + else + { + //鏁版嵁閰嶇疆閿欒 + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); + WriteInfo(task.DeviceCode, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); + return null; + } + } + else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) + { + string[] targetCodes = task.NextAddress.Split("-"); + + if (targetCodes.Length == 3) { stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); @@ -317,25 +328,17 @@ else { //鏁版嵁閰嶇疆閿欒 - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); - WriteInfo(task.DeviceCode, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); + WriteInfo(task.DeviceCode, $"鍑哄簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); return null; } - } - else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) - { - string[] targetCodes = task.NextAddress.Split("-"); - - stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); - stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); - stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); string[] sourceCodes = task.CurrentAddress.Split("-"); if (sourceCodes.Length == 5) { - stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); - stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); - stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]); } else { @@ -350,23 +353,23 @@ string[] targetCodes = task.NextAddress.Split("-"); if (targetCodes.Length == 5) { - stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); - stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); - stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); + stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); + stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); + stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]); } else { //鏁版嵁閰嶇疆閿欒 - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); - WriteInfo(task.DeviceCode, $"绉诲簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"绉诲簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); + WriteInfo(task.DeviceCode, $"绉诲簱浠诲姟缁堢偣閿欒锛岀粓鐐癸細銆恵task.NextAddress}銆�"); return null; } string[] sourceCodes = task.CurrentAddress.Split("-"); if (sourceCodes.Length == 5) { - stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); - stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); - stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]); } else { diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/4c556b7e-ac07-429f-bc24-3cd592323521.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/4c556b7e-ac07-429f-bc24-3cd592323521.vsidx" new file mode 100644 index 0000000..28b5513 --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/4c556b7e-ac07-429f-bc24-3cd592323521.vsidx" Binary files differ diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskEnumHelper.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskEnumHelper.cs" index 5ddce7c..711654b 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskEnumHelper.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskEnumHelper.cs" @@ -14,5 +14,25 @@ if (!type.IsEnum) return new List<int>(); return Enum.GetValues(type).Cast<int>().ToList(); } + + public static TaskTypeGroup GetTaskTypeGroup(this int taskType) + { + if (taskType >= 500 && taskType < 900) + { + return TaskTypeGroup.InboundGroup; + } + else if (taskType >= 100 && taskType < 500) + { + return TaskTypeGroup.OutbondGroup; + } + else if (taskType >= 900 && taskType < 1000) + { + return TaskTypeGroup.RelocationGroup; + } + else + { + return TaskTypeGroup.OtherGroup; + } + } } } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs" index e2a252e..668fe03 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/TaskEnum/TaskTypeEnum.cs" @@ -61,4 +61,27 @@ Relocation = 900 } + + public enum TaskTypeGroup + { + /// <summary> + /// + /// </summary> + InboundGroup, + + /// <summary> + /// + /// </summary> + OutbondGroup, + + /// <summary> + /// + /// </summary> + RelocationGroup, + + /// <summary> + /// + /// </summary> + OtherGroup + } } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/PermissionDataHostService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/PermissionDataHostService.cs" index 95b79b2..1656f81 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/PermissionDataHostService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/HostedService/PermissionDataHostService.cs" @@ -30,7 +30,21 @@ public Task StartAsync(CancellationToken cancellationToken) { - List<ExpandoObject> roles = _dbContext.Db.Queryable("Sys_Role", "x").Select(RoleSelectModes).ToList(); + List<UserRole> userRoles = GetUserRoles(_dbContext.Db); + UserRoles = userRoles; + _cacheService.AddOrUpdate("UserRoles", userRoles.Serialize()); + + return Task.CompletedTask; + } + + public Task StopAsync(CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } + + public static List<UserRole> GetUserRoles(ISqlSugarClient db) + { + List<ExpandoObject> roles = db.Queryable("Sys_Role", "x").Select(RoleSelectModes).ToList(); List<dynamic> roleDynamics = new List<dynamic>(); foreach (var item in roles) { @@ -38,13 +52,13 @@ } List<dynamic> roleDataDynamics = new List<dynamic>(); - List<ExpandoObject> roleDatas = _dbContext.Db.Queryable("Sys_RoleDataPermission", "x").Select(RoleDataSelectModes).ToList(); + List<ExpandoObject> roleDatas = db.Queryable("Sys_RoleDataPermission", "x").Select(RoleDataSelectModes).ToList(); foreach (var item in roleDatas) { roleDataDynamics.Add(item); } - List<ExpandoObject> users = _dbContext.Db.Queryable("Sys_User", "x").Select(UserSelectModes).ToList(); + List<ExpandoObject> users = db.Queryable("Sys_User", "x").Select(UserSelectModes).ToList(); List<UserRole> userRoles = new List<UserRole>(); foreach (var item in users) @@ -70,19 +84,10 @@ }); } } - - UserRoles = userRoles; - _cacheService.AddOrUpdate("UserRoles", userRoles.Serialize()); - - return Task.CompletedTask; + return userRoles; } - public Task StopAsync(CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - List<SelectModel> RoleSelectModes = new List<SelectModel>() + static List<SelectModel> RoleSelectModes = new List<SelectModel>() { new SelectModel() { @@ -98,7 +103,7 @@ }, }; - List<SelectModel> UserSelectModes = new List<SelectModel>() + static List<SelectModel> UserSelectModes = new List<SelectModel>() { new SelectModel() { @@ -118,7 +123,7 @@ } }; - List<SelectModel> RoleDataSelectModes = new List<SelectModel>() + static List<SelectModel> RoleDataSelectModes = new List<SelectModel>() { new SelectModel() { diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/InitializationLocationDTO.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/InitializationLocationDTO.cs" index d56858d..cd6e309 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/InitializationLocationDTO.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/InitializationLocationDTO.cs" @@ -37,7 +37,7 @@ /// <summary> /// 鏄惁鍗曟繁璐т綅 /// </summary> - [PropertyValidate("娣卞害", MinValue = 1, NotNullAndEmpty = true)] + [PropertyValidate("娣卞害", MinValue = 1, NotNullAndEmpty = true, IsContainMinValue = true)] public int Depth { get; set; } } } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs" index 10078f3..3963410 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_ITaskInfoService/ITaskService.cs" @@ -41,6 +41,8 @@ WebResponseContent PushTasksToWCS(List<Dt_Task> tasks, string agvDescription = ""); + WebResponseContent PushTasksToWCSSingle(int taskNum, string agvDescription = ""); + /// <summary> /// 鐢宠鍏ュ簱浠诲姟(PDA浣跨敤锛屼粎鎵樼洏缁戝畾鍏ュ簱绔欏彴锛屼笉鍒嗛厤璐т綅) /// </summary> @@ -59,6 +61,8 @@ /// <returns></returns> WebResponseContent AssignInboundTaskLocation(int taskNum, string roadwayNo); + WebResponseContent TaskCompleted(int taskNum); + /// <summary> /// /// </summary> diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs" index ff749a1..b71749e 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs" @@ -16,6 +16,7 @@ using WIDESEA_Model.Models.System; using WIDESEA_SystemRepository; using WIDESEA_Core.Helper; +using WIDESEA_Core.HostedService; namespace WIDESEA_SystemService { @@ -38,7 +39,7 @@ public override WebResponseContent AddData(SaveModel saveModel) { - string authorityScope = saveModel.MainData["authorityScope"].ToString(); + string authorityScope = saveModel.MainData["authorityScope"].ToString() ?? ""; Sys_Role role = saveModel.MainData.DicToModel<Sys_Role>(); if (BaseDal.QueryFirst(x => x.RoleName == role.RoleName) != null) { @@ -71,12 +72,14 @@ BaseDal.Db.Insertable(roleDataPermissions).ExecuteCommand(); } + PermissionDataHostService.UserRoles = PermissionDataHostService.GetUserRoles(Db); + return WebResponseContent.Instance.OK(); } public override WebResponseContent UpdateData(SaveModel saveModel) { - string authorityScope = saveModel.MainData["authorityScope"].ToString(); + string authorityScope = saveModel.MainData["authorityScope"].ToString() ?? ""; Sys_Role role = saveModel.MainData.DicToModel<Sys_Role>(); if (BaseDal.QueryFirst(x => x.RoleId == role.RoleId) == null) { @@ -116,6 +119,8 @@ BaseDal.Db.Insertable(roleDataPermissions).ExecuteCommand(); BaseDal.Db.Deleteable(oldDatas).ExecuteCommand(); + PermissionDataHostService.UserRoles = PermissionDataHostService.GetUserRoles(Db); + return WebResponseContent.Instance.OK(); } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs" index 5d4650e..5717f5c 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Completed.cs" @@ -1,4 +1,5 @@ -锘縰sing System; +锘縰sing Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -17,22 +18,65 @@ { public partial class TaskService { - //public WebResponseContent TaskCompleted(int taskNum) - //{ - // try - // { - // Dt_Task task = Repository.QueryFirst(x => x.TaskNum == taskNum); - // if (task == null) - // { - // return WebResponseContent.Instance.Error($"鏈壘鍒颁换鍔′俊鎭�"); - // } - // if(task.TaskType.get) - - // } - // catch (Exception ex) - // { - // return WebResponseContent.Instance.Error(ex.Message); - // } - //} + public WebResponseContent TaskCompleted(int taskNum) + { + try + { + Dt_Task task = Repository.QueryFirst(x => x.TaskNum == taskNum); + if (task == null) + { + return WebResponseContent.Instance.Error($"鏈壘鍒颁换鍔′俊鎭�"); + } + if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) + { + return InboundTaskCompleted(taskNum); + } + else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) + { + return OutboundTaskCompleted(taskNum); + } + else if (task.TaskType.GetTaskTypeGroup() != TaskTypeGroup.RelocationGroup) + { + return RelocationTaskCompleted(task); + } + else + { + return WebResponseContent.Instance.Error($"鏈壘鍒拌绫诲瀷浠诲姟,浠诲姟绫诲瀷:{task.TaskType}"); + } + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + } + + /// <summary> + /// 浠诲姟淇℃伅鎺ㄩ�佽嚦WCS + /// </summary> + /// <returns></returns> + public WebResponseContent PushTasksToWCSSingle(int taskNum, string agvDescription = "") + { + try + { + Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); + if (task == null) + { + return WebResponseContent.Instance.Error($"閿欒,鏈壘鍒拌浠诲姟淇℃伅"); + } + + List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { _mapper.Map<WMSTaskDTO>(task) }; + taskDTOs.ForEach(x => + { + x.AGVArea = agvDescription; + }); + string response = HttpHelper.Post("http://127.0.0.1:9291/api/Task/ReceiveTask", taskDTOs.Serialize()); + + return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒"); + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + } } } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" index 183f715..699e6ea 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" @@ -64,6 +64,7 @@ TargetAddress = "", TaskType = TaskTypeEnum.Inbound.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), + WarehouseId = warehouseId }; stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); @@ -73,7 +74,7 @@ newTask.TaskId = taskId; _stockRepository.StockInfoRepository.UpdateData(stockInfo); _unitOfWorkManage.CommitTran(); - + PushTasksToWCS(new List<Dt_Task> { newTask }); return WebResponseContent.Instance.OK(data: newTask); } catch (Exception ex) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" index 188e1b7..a6dd362 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" @@ -215,7 +215,7 @@ _unitOfWorkManage.BeginTran(); BaseDal.AddData(tasks); - if (stockInfos != null && outboundOrderDetails != null && outStockLockInfos != null && locationInfos != null) + if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) { WebResponseContent content = _outboundService.OutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); @@ -239,6 +239,7 @@ _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); } _unitOfWorkManage.CommitTran(); + PushTasksToWCS(tasks); return WebResponseContent.Instance.OK(); } catch (Exception ex) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs" index e53c4fa..2f7fd80 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskInfo/TaskController.cs" @@ -101,10 +101,39 @@ return Service.OutboundTaskCompleted(taskNum); } + /// <summary> + /// 鍒ゆ柇鏄惁闇�瑕佺Щ搴� + /// </summary> + /// <param name="taskNum">浠诲姟鍙�</param> + /// <param name="locationCode"></param> + /// <returns></returns> [HttpPost, HttpGet, Route("IsRelocation"), AllowAnonymous] public WebResponseContent IsRelocation(int taskNum, string locationCode) { return Service.IsRelocation(taskNum, locationCode); } + + /// <summary> + /// 浠诲姟瀹屾垚 + /// </summary> + /// <param name="taskNum">浠诲姟鍙�</param> + /// <returns></returns> + [HttpPost, HttpGet, Route("TaskCompleted"), AllowAnonymous] + public WebResponseContent TaskCompleted(int taskNum) + { + return Service.TaskCompleted(taskNum); + } + + /// <summary> + /// 鍗曚釜浠诲姟鎺ㄩ�佽嚦WCS + /// </summary> + /// <param name="taskNum">浠诲姟鍙�</param> + /// <param name="agvDescription"></param> + /// <returns></returns> + [HttpPost, HttpGet, Route("PushTasksToWCSSingle"), AllowAnonymous] + public WebResponseContent PushTasksToWCSSingle(int taskNum, string agvDescription = "") + { + return Service.PushTasksToWCSSingle(taskNum, agvDescription); + } } } -- Gitblit v1.9.3