更新.gitignore以排除SemanticSymbols.db文件,新增MemoryLockManager类以管理任务锁,优化Dt_TaskService中的入库任务创建逻辑
已删除1个文件
已修改2个文件
已添加1个文件
131 ■■■■■ 文件已修改
.gitignore 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/MemoryLockManager.cs 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.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
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/MemoryLockManager.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,40 @@
namespace 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();
            }
        }
    }
}
Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.12.31.40377/SemanticSymbols.db
Binary files differ
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,5 +1,4 @@
using AngleSharp.Io;
using Mapster;
using 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  é™ç½®å¼‚常口入库
    #region é™ç½®å¼‚常口入库
    #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 é™ç½®å¼‚常口入库
    #endregion å¤–部接口方法