From 557058f03533e730f5379e311f492f471244969a Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期六, 21 十二月 2024 11:00:03 +0800 Subject: [PATCH] 更新.gitignore以排除SemanticSymbols.db文件,新增MemoryLockManager类以管理任务锁,优化Dt_TaskService中的入库任务创建逻辑 --- /dev/null | 0 .gitignore | 1 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 90 ++++++++++++++++++++++++++++- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/MemoryLockManager.cs | 40 +++++++++++++ 4 files changed, 126 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 1c7d00e..c3f7b2a 100644 --- a/.gitignore +++ b/.gitignore @@ -1578,3 +1578,4 @@ /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/CodeChunks.db-wal /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db-shm /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db-wal +/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/MemoryLockManager.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/MemoryLockManager.cs new file mode 100644 index 0000000..8fe2e7a --- /dev/null +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/MemoryLockManager.cs @@ -0,0 +1,40 @@ +锘縩amespace WIDESEAWCS_Tasks +{ + public static class MemoryLockManager + { + private static Dictionary<string, SemaphoreSlim> _locks = new Dictionary<string, SemaphoreSlim>(); + + /// <summary> + /// 寮�鍚攣 + /// </summary> + /// <param name="jobName"></param> + /// <returns></returns> + public static bool TryAcquireLock(string jobName) + { + if (!_locks.ContainsKey(jobName)) + { + _locks[jobName] = new SemaphoreSlim(1, 1); + } + try + { + return _locks[jobName].Wait(0); + } + catch (Exception) + { + return false; + } + } + + /// <summary> + /// 閲婃斁閿� + /// </summary> + /// <param name="jobName"></param> + public static void ReleaseLock(string jobName) + { + if (_locks.ContainsKey(jobName)) + { + _locks[jobName].Release(); + } + } + } +} \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db b/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db deleted file mode 100644 index 65c123f..0000000 --- a/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db +++ /dev/null Binary files differ diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs index bf8748c..000de4c 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs @@ -1,5 +1,4 @@ -锘縰sing AngleSharp.Io; -using Mapster; +锘縰sing Mapster; using Masuit.Tools; using System.Text.RegularExpressions; using WIDESEA_Core.Const; @@ -429,7 +428,6 @@ if (boxing.ProcessCode == "OCV1") area = _areaInfoRepository.QueryFirst(x => x.AreaID == 6); - else if (boxing.ProcessCode == "OCVB") area = _areaInfoRepository.QueryFirst(x => x.AreaID == 7); @@ -1323,9 +1321,91 @@ #endregion 鎸囧畾浠诲姟鍑哄簱 - #region 闈欑疆寮傚父鍙e叆搴� + #region 闈欑疆寮傚父鍙e叆搴� - #endregion + public async Task<WebResponseContent> CreateAndSendInboundTask(string locationCode, string palletCode, string position) + { + WebResponseContent content = new WebResponseContent(); + try + { + // 鏌ヨ搴撳瓨淇℃伅 + var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode); + if (stockInfo == null) + { + var area = _areaInfoRepository.QueryFirst(x => x.AreaID == 2); + var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == position); + TrayCellsStatusDto trayCells = CreateTrayCellsStatusDto(area, palletCode); + content = await GetTrayCellStatusAsync(trayCells); + if (!content.Status) return content; + + var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); + if (!result.Success) + { + if (result.SerialNos.Count <= 0) + { + var location = await GetLocationDistributeAsync(station.Roadway); + // 鍒涘缓鏂颁换鍔″疄渚� + var task = new Dt_Task + { + CurrentAddress = locationCode, + Grade = 1, + Roadway = station.Roadway, + TargetAddress = location.LocationCode, + Dispatchertime = DateTime.Now, + MaterialNo = "", + NextAddress = location.LocationCode, + OrderNo = null, + PalletCode = palletCode, + SourceAddress = locationCode, + TaskState = (int)TaskInStatusEnum.Line_InFinish, + TaskType = (int)TaskInboundTypeEnum.Inbound, + TaskNum = await BaseDal.GetTaskNo(), + Creater = "Systeam" + }; + + // 鍒涘缓WMS浠诲姟 + WMSTaskDTO taskDTO = new WMSTaskDTO() + { + TaskNum = task.TaskNum.Value, + Grade = 1, + PalletCode = task.PalletCode, + RoadWay = task.Roadway, + SourceAddress = task.SourceAddress, + TargetAddress = task.Roadway, + TaskState = task.TaskState.Value, + Id = 0, + TaskType = task.TaskType, + }; + + await _unitOfWorkManage.UseTranAsync(async () => + { + // 娣诲姞浠诲姟鍒版暟鎹簱 + await BaseDal.AddDataAsync(task); + // 鏇存柊搴撳瓨浣嶇疆鐘舵�佷负涓嶅彲鐢� + location.LocationStatus = (int)LocationEnum.InStockDisable; + await _locationRepository.UpdateDataAsync(location); + }); + + content.OK(data: taskDTO); + } + else + content.Error(result.MOMMessage); + } + } + else + { + // TODO璐ㄦ鍥炲簱 + var area = _areaInfoRepository.QueryFirst(x => x.AreaID == 2); + } + } + catch (Exception ex) + { + content.Error(ex.Message); + } + return content; + } + + #endregion 闈欑疆寮傚父鍙e叆搴� #endregion 澶栭儴鎺ュ彛鏂规硶 -- Gitblit v1.9.3