schangxiang@126.com
2024-04-25 0343f06a2b1097662d12780829f247b094111320
生成助记码
已添加5个文件
已修改2个文件
21254 ■■■■■ 文件已修改
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsCommon/IWmsCommonService.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsCommon/WmsCommonService.cs 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Core/Util/ChineseSpell/MnemonicCodeUtil.cs 232 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ChineseSpellFile/hzpy1.txt 20975 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ChineseSpellFile/hzpy2.txt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ChineseSpellFile/hzpy3.txt 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ChineseSpellFile/hzwb.txt 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsCommon/IWmsCommonService.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Authorization;
namespace Admin.NET.Application
{
@@ -13,5 +14,13 @@
        /// </summary>
        /// <returns></returns>
        Task<string> GetSerial([FromQuery] EnumSerialType SerialType);
        /// <summary>
        /// ç”ŸæˆåŠ©è®°ç 
        /// æ³¨æ„ï¼šåªèƒ½è°ƒè¿™ä¸ªæŽ¥å£ï¼Œä¸èƒ½è‡ªå·±å†™æ–¹æ³•调,否则可能会导致文件读取冲突造成错误!
        /// </summary>
        /// <returns></returns>
        Task<string> GetMnemonicCode([FromQuery] string name);
    }
}
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();
            }
        }
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Core/Util/ChineseSpell/MnemonicCodeUtil.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,232 @@
using Furion;
using System.Text;
namespace Admin.NET.Core
{
    /// <summary>
    /// ç”ŸæˆåŠ©è®°ç 
    /// </summary>
    public class MnemonicCodeUtil
    {
        private struct ItemWord
        {
            public int numFlag;     //是否多音字
            public char strWord;    //当前单词
            public string strSpell1;//输入码1
            public string strSpell2;//输入码2
            public string strExt;   //多音字保留串
            public string strName;  //用于定义姓氏码
        }
        private static readonly int INTMAX = 65536;
        private static ItemWord[] stWord = new ItemWord[INTMAX];
        private static Boolean b_LoadData = false;
        //读取所有汉字
        public static Boolean fun_LoadWords()
        {
            int i, numIndex;
            int numCount1, numCount2;
            string strFileName;
            char[] chrWord;
            if (b_LoadData)
                return true;
            //以下初始化所有的数据
            for (i = 0; i < INTMAX; i++)
            {
                stWord[i].numFlag = 0;
                stWord[i].strSpell1 = "";
                stWord[i].strSpell2 = "";
                stWord[i].strName = "";
                stWord[i].strExt = "|";
            }
            var rootPath = System.IO.Path.Combine(App.WebHostEnvironment.WebRootPath, "ChineseSpellFile");
            //读取汉字拼音
            strFileName = rootPath + @"\hzpy1.txt";
            StreamReader srFile = new StreamReader(strFileName, Encoding.ASCII);
            string strInput = null;
            numCount1 = 0;
            while ((strInput = srFile.ReadLine()) != null)
            {
                chrWord = strInput.ToCharArray();
                numIndex = (int)chrWord[0];
                if (numIndex <= 0) continue;
                if (numIndex >= INTMAX) continue;
                stWord[numIndex].strWord = chrWord[0];
                stWord[numIndex].strSpell1 = chrWord[2].ToString();
                numCount1++;
            }
            srFile.Close();
            //读取多音字
            strFileName = rootPath + @"\hzpy2.txt";
            srFile = new StreamReader(strFileName, Encoding.ASCII);
            while ((strInput = srFile.ReadLine()) != null)
            {
                chrWord = strInput.ToCharArray();
                numIndex = (int)chrWord[0];
                if (numIndex <= 0) continue;
                if (numIndex >= INTMAX) continue;
                stWord[numIndex].numFlag = 1;
                strInput = strInput.Substring(2);
                strInput = strInput.Replace("\t", " ");
                while (strInput.IndexOf("  ") >= 0)
                {
                    strInput = strInput.Replace("  ", " ");
                }
                strInput = strInput.Replace(" ", "/");
                stWord[numIndex].strExt = stWord[numIndex].strExt + strInput + "|";
            }
            srFile.Close();
            //读取姓氏
            strFileName = rootPath + @"\hzpy3.txt";
            srFile = new StreamReader(strFileName, Encoding.ASCII);
            while ((strInput = srFile.ReadLine()) != null)
            {
                chrWord = strInput.ToCharArray();
                numIndex = (int)chrWord[0];
                if (numIndex <= 0) continue;
                if (numIndex >= INTMAX) continue;
                stWord[numIndex].numFlag = 1;
                strInput = strInput.Substring(2);
                strInput = strInput.Replace("\t", " ");
                while (strInput.IndexOf("  ") >= 0)
                {
                    strInput = strInput.Replace("  ", " ");
                }
                stWord[numIndex].strName = strInput;
            }
            srFile.Close();
            //以下部分读取五笔码的首字符
            strFileName = rootPath + @"\hzwb.txt";
            numCount2 = 0;
            srFile = new StreamReader(strFileName, Encoding.ASCII);
            while ((strInput = srFile.ReadLine()) != null)
            {
                chrWord = strInput.ToCharArray();
                numIndex = (int)chrWord[0];
                if (numIndex <= 0) continue;
                if (numIndex >= INTMAX) continue;
                stWord[numIndex].strWord = chrWord[0];
                stWord[numIndex].strSpell2 = chrWord[1].ToString();
                numCount2++;
            }
            srFile.Close();
            b_LoadData = true;
            return true;
        }
        private static string funFindMulti(int numIndex, char ch1, char ch2)
        {
            int numPos;
            string strWord;
            strWord = "|" + ch1 + ch2 + "/";
            numPos = stWord[numIndex].strExt.IndexOf(strWord);
            if (numPos >= 0)
                return stWord[numIndex].strExt.Substring(numPos + strWord.Length, 1);
            return "";
        }
        /// <summary>
        /// åŠ©è®°ç (拼音)
        /// </summary>
        /// <param name="strChinese"></param>
        /// <param name="IsName"></param>
        /// <returns></returns>
        public static string funChineseSpell(string strChinese, bool IsName)
        {
            string strSpell, strThis;
            int i, numCount, numIndex;
            char[] chrWord;
            strSpell = "";
            chrWord = strChinese.ToCharArray();
            numCount = strChinese.Length;
            //2010-03-19 ä¾æ¬¡å¤„理各汉字的拼音码
            for (i = 0; i < numCount; i++)
            {
                numIndex = (int)chrWord[i];
                if (numIndex <= 0) continue;
                if (numIndex >= INTMAX) continue;
                //2010-03-19 æ˜¯å¦å¤šéŸ³å­—
                strThis = "";
                if (stWord[numIndex].numFlag > 0 && !IsName)
                {
                    if (i > 0)
                    {
                        strThis = funFindMulti(numIndex, chrWord[i - 1], chrWord[i]);
                    }
                    if (strThis.Length == 0)
                    {
                        if (i < numCount - 1)
                            strThis = funFindMulti(numIndex, chrWord[i], chrWord[i + 1]);
                    }
                }
                //2010-04-02 æŒ‰å§“名进行处理
                if (IsName && i == 0 && stWord[numIndex].strName.Length > 0)
                    strThis = stWord[numIndex].strName;
                //2010-03-20 æœªæ‰¾ç€æ—¶æ˜¯æ ‡å‡†ç 
                if (strThis.Length == 0)
                    strThis = stWord[numIndex].strSpell1.ToString();
                strSpell = strSpell + strThis;
            }
            return strSpell;
        }
        /// <summary>
        /// åŠ©è®°ç (五笔)
        /// </summary>
        /// <param name="strChinese"></param>
        /// <returns></returns>
        public string funWbzxSpell(string strChinese)
        {
            string strSpell = "";
            int i, numCount, numIndex;
            char[] chrWord;
            strSpell = "";
            chrWord = strChinese.ToCharArray();
            numCount = strChinese.Length;
            //2010-03-19 ä¾æ¬¡å¤„理各汉字的五笔编码
            for (i = 0; i < numCount; i++)
            {
                numIndex = (int)chrWord[i];
                if (numIndex <= 0) continue;
                if (numIndex >= INTMAX) continue;
                strSpell = strSpell + stWord[numIndex].strSpell2.ToString();
            }
            return strSpell;
        }
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ChineseSpellFile/hzpy1.txt
¶Ô±ÈÐÂÎļþ
ÎļþÌ«´ó
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ChineseSpellFile/hzpy2.txt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,5 @@
参 äººå‚ S
长 é•¿æ˜¥ C
宿 å½’宿 S
曾 æ›¾å“¥ Z
单 å•于 C
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ChineseSpellFile/hzpy3.txt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,3 @@
曾 Z
查 Z
单 S
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ChineseSpellFile/hzwb.txt
Binary files differ