schangxiang@126.com
2024-04-25 0343f06a2b1097662d12780829f247b094111320
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsCommon/WmsCommonService.cs
@@ -19,6 +19,7 @@
    public class WmsCommonService : IWmsCommonService, IDynamicApiController, ITransient
    {
        private static readonly SemaphoreSlim semaphore_GetMnemonicCode = new SemaphoreSlim(1, 1);//SemaphoreSlim实例,并设置最大并发访问数为1。
        /// <summary>
        /// 构造函数
@@ -40,6 +41,35 @@
            var returnstr = await SerialUtil.GetSerial(SerialType);
            return returnstr;
        }
        /// <summary>
        /// 生成助记码
        /// 注意:只能调这个接口,不能自己写方法调,否则可能会导致文件读取冲突造成错误!
        /// </summary>
        /// <returns></returns>
        [HttpGet("WmsCommon/getMnemonicCode")]
        [AllowAnonymous]
        public async Task<string> GetMnemonicCode([FromQuery] string name)
        {
            await semaphore_GetMnemonicCode.WaitAsync();
            try
            {
                MnemonicCodeUtil.fun_LoadWords();
                var retMsg = MnemonicCodeUtil.funChineseSpell(name, false);
                return retMsg;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                semaphore_GetMnemonicCode.Release();
            }
        }
    }
}