From ce72deb4068917547d97c3e8991dde8772728d25 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期四, 30 四月 2026 15:16:36 +0800
Subject: [PATCH] 2

---
 WebAPI/Controllers/WebAPIController.cs |  312 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 300 insertions(+), 12 deletions(-)

diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs
index ab61d72..0bba5be 100644
--- a/WebAPI/Controllers/WebAPIController.cs
+++ b/WebAPI/Controllers/WebAPIController.cs
@@ -20,6 +20,7 @@
 using WebAPI.Models;
 using WebAPI.Service;
 using SyntacticSugar.constant;
+using System.Text.RegularExpressions;
 
 namespace WebAPI.Controllers
 {
@@ -340,6 +341,7 @@
         /// <returns></returns>
         [Route("Web/GetUser")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetUser(string UserName, string PassWord, string HOrgName)
         {
             try
@@ -384,11 +386,23 @@
                     }
                 }
 
+                if (!oSystemParameter.ShowBill(ref DBUtility.ClsPub.sErrInfo))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鐧诲綍寮傚父锛乀oken 鐢熸垚寮傚父锛屾棤娉曡幏鍙栧叕鍙镐俊鎭紒";
+                }
+
+                string tokenStr = Utility.JWTHelper.GenerateToken(ds.Tables[0].Rows[0]["Czybm"].ToString(), ds.Tables[0].Rows[0]["Czymc"].ToString());
+
+
                 objjson.code = "0";
                 objjson.count = 1;
                 objjson.Message = "[0000-1-073]鐧诲綍鎴愬姛锛�";
                 objjson.data = ds.Tables[0];
-                return objjson;
+                JObject jobjJsonResult = JObject.FromObject(objjson);
+                jobjJsonResult["token"] = tokenStr;
+                return jobjJsonResult;
 
             }
             catch (Exception e)
@@ -396,7 +410,7 @@
 
                 objjson.code = "0";
                 objjson.count = 0;
-                objjson.Message = "[0000-1-074]鐧诲綍寮傚父锛�" + e.Message;
+                objjson.Message = "[0000-1-074]鐧诲綍寮傚父锛�" + e;
                 objjson.data = null;
                 return objjson; ;
             }
@@ -2619,6 +2633,7 @@
         /// <returns></returns>
         [Route("Web/GetDataBases")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetDataBases()
         {
             try
@@ -18965,6 +18980,7 @@
         /// <returns></returns>
         [Route("Web/GetOrganizations")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetOrganizations()
         {
             try
@@ -18997,6 +19013,7 @@
         /// <returns></returns>
         [Route("Web/BaseInfo")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetBaseInfo()
         {
             try
@@ -20457,7 +20474,7 @@
             {
                 objjson.code = "0";
                 objjson.count = 0;
-                objjson.Message = "鑾峰彇澶辫触" + ex.ToString();
+                objjson.Message = "鑾峰彇澶辫触" + ex.Message.ToString();
                 objjson.data = null;
                 return objjson;
             }
@@ -20952,7 +20969,18 @@
                 {
                     objjson.code = "0";
                     objjson.count = 0;
-                    objjson.Message = "鑾峰彇澶辫触,鏄庣粏鏌ユ棤鏁版嵁";
+                    if(Type == "DJ")
+                    {
+                        objjson.Message = "鑾峰彇澶辫触,妯″叿鏃犵粦瀹氱殑鐐规瑙勭▼";
+                    }
+                    else if (Type == "BY")
+                    {
+                        objjson.Message = "鑾峰彇澶辫触,妯″叿鏃犵粦瀹氱殑淇濆吇瑙勭▼";
+                    }
+                    else
+                    {
+                        objjson.Message = "鑾峰彇澶辫触,鏄庣粏鏌ユ棤鏁版嵁";
+                    }
                     objjson.data = null;
                     return objjson;
                 }
@@ -21153,12 +21181,12 @@
 
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
 
-                ds = oCN.RunProcReturn("select ManagerFlag from gy_czygl where czymc='" + user.Trim() + "'", "gy_czygl");
-                if (!(bool)ds.Tables[0].Rows[0]["ManagerFlag"])  //鏄惁绠$悊鍛�
-                {
-                    //涓嶆槸绠$悊鍛�
-                    sWhere += " and 鍒跺崟浜� = '" + user + "'";
-                }
+                //ds = oCN.RunProcReturn("select ManagerFlag from gy_czygl where czymc='" + user.Trim() + "'", "gy_czygl");
+                //if (!(bool)ds.Tables[0].Rows[0]["ManagerFlag"])  //鏄惁绠$悊鍛�
+                //{
+                //    //涓嶆槸绠$悊鍛�
+                //    sWhere += " and 鍒跺崟浜� = '" + user + "'";
+                //}
 
 
                 string sql = string.Format(@"select * from " + HView + " where 1 = 1 " + sWhere + " order by 鏃ユ湡 desc, hmainid desc");
@@ -22836,6 +22864,7 @@
         /// <returns></returns>
         [Route("Web/GetModuleName")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetModuleName(string HModuleType)
         {
             try
@@ -23439,6 +23468,7 @@
         #region 鐢ㄤ簬杩炴帴鐨勫仴搴峰害妫�楠岋紝鍙鑳借闂�氳繖涓帴鍙o紝鍒欒〃鏄庤繛鎺ュ彲鐢�
         [Route("Health")]
         [HttpGet]
+        [AllowAnonymous]
         public IHttpActionResult CheckHealth()
         {
             // 杩斿洖 200 鐘舵�佺爜 纭鍋ュ悍鐘舵��
@@ -23905,11 +23935,15 @@
                 foreach (var param in rawParams)
                 {
                     bool isMatched = false;
-                    // 閬嶅巻鎵�鏈夊伐鑹哄垎绫伙紝鍒ゆ柇鍙傛暟鍚嶆槸鍚﹀寘鍚鍒嗙被鍚嶇О
+                    // 閬嶅巻鎵�鏈夊伐鑹哄垎绫伙紝鍒ゆ柇鍙傛暟鍚嶆槸浠ヨ鍒嗙被鍚嶇О寮�澶�
                     foreach (string category in categoryNames)
                     {
-                        if (param.TechParamName.Contains(category))
+                        if (param.TechParamName.StartsWith(category))
                         {
+                            if(param.TechParamName.Length != category.Length)
+                            {
+                                param.TechParamName = param.TechParamName.Substring(category.Length);
+                            }
                             groupedParams[category].Add(param);
                             isMatched = true;
                             break; // 鍖归厤鍒扮涓�涓垎绫诲悗鍋滄锛堥伩鍏嶉噸澶嶅尮閰嶏級
@@ -23971,5 +24005,259 @@
             }
         }
         #endregion
+
+        #region  APP鐧诲綍鏉冮檺楠岃瘉鎺ュ彛
+        /// <summary>
+        /// APP鐧诲綍鏉冮檺楠岃瘉鎺ュ彛
+        /// </summary>
+        [Route("Auth/CheckAppLoginAuth")]
+        [HttpPost]
+        public object CheckAppLoginAuth()
+        {
+            try
+            {
+                // 鑾峰彇璇锋眰鍙傛暟
+                string orgID = HttpContext.Current.Request.Form["orgID"] ?? "";
+                string orgName = HttpContext.Current.Request.Form["orgName"] ?? "";
+                string serverUrl = HttpContext.Current.Request.Form["serverUrl"] ?? "";
+                string phoneType = HttpContext.Current.Request.Form["phoneType"] ?? "";
+                string userAccount = HttpContext.Current.Request.Form["userAccount"] ?? "";
+                string other = HttpContext.Current.Request.Form["other"] ?? "";
+                // 鍙傛暟楠岃瘉
+                if (string.IsNullOrEmpty(userAccount))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "璐﹀彿涓嶈兘涓虹┖!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrEmpty(orgID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "缁勭粐ID涓嶈兘涓虹┖!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                // 鍙傛暟瀹夊叏澶勭悊锛堥槻姝㈡敞鍏ワ級
+                orgID = orgID.Replace("'", "''");
+                orgName = orgName.Replace("'", "''");
+                serverUrl = serverUrl.Replace("'", "''");
+                phoneType = phoneType.Replace("'", "''");
+                userAccount = userAccount.Replace("'", "''");
+
+                // 鎵ц鍥哄畾瀛樺偍杩囩▼
+                string sql = $"EXEC SP_CheckAppLoginAuth '{orgID}', '{orgName}', '{serverUrl}', '{phoneType}','{userAccount}','{other}'";
+                ds = oCN.RunProcReturn(sql, "SP_CheckAppLoginAuth");
+
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    int result = Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]);
+                    string message = ds.Tables[0].Rows[0]["Message"].ToString();
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = message;
+                    objJsonResult.data = ds.Tables[0];
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "楠岃瘉鎺ュ彛杩斿洖寮傚父!";
+                    objJsonResult.data = null;
+                }
+
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 钃濈墮鎵撳嵃鏈鸿幏鍙栨墦鍗版ā鏉�
+        public class PrintRequestDto
+        {
+            public string ptMode { get; set; }
+            public string templateName { get; set; }
+            public JArray msg { get; set; } // 浣犵殑鎵归噺鏁版嵁
+        }
+        /// <summary>
+        /// ptMode: 鎵撳嵃妯″紡锛屽嵆闇�瑕侀偅绉嶆墦鍗版寚浠わ紝CPCL,TSPL,ESC,ZPL 涓�夋嫨
+        /// templateName: 妯℃澘鍚嶏紝鏍规嵁妯℃澘鍘绘寚瀹氱洰褰曚笅鏍规嵁鍚庣紑鎵炬枃浠�
+        /// msg: 鎵撳嵃鍐呭
+        /// </summary>
+        /// <param name="ptMode"></param>
+        /// <param name="templateName"></param>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("WebAPI/getBLEPrintTemplate")]
+        [HttpPost]
+        public object getBLEPrintTemplate([FromBody] PrintRequestDto dto)
+        {
+            var ptMode = dto.ptMode;
+            var templateName = dto.templateName;
+            var msg = dto.msg;
+            if (string.IsNullOrWhiteSpace(ptMode))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏈�夋嫨鎵撳嵃妯″紡锛屾棤娉曠敓鎴愭墦鍗版ā鏉�!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            if (string.IsNullOrWhiteSpace(templateName))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏈�夋嫨鎵撳嵃妯℃澘锛屾棤娉曠敓鎴愭墦鍗版ā鏉�!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            string suffix = ".txt";
+            string folder = "ptTemplate";
+            // 鍖归厤 {{ 瀛楁鍚� }} 鎵�闇�姝e垯琛ㄨ揪寮� 鏀寔涓枃
+            var regex = new Regex(@"{{\s*([\u4e00-\u9fa5a-zA-Z0-9_\s]+?)\s*}}", RegexOptions.Compiled);
+
+            if (ptMode == "ZPL")
+            {
+                suffix = ".zpl";
+                folder = "ZPLTemplate";
+            }
+
+            try
+            {
+                // 璇诲彇妯℃澘鏂囦欢
+                string rootPath = System.Web.HttpContext.Current.Server.MapPath("~/");
+                string templateDir = Path.Combine(rootPath, folder);
+                string templateFile = Path.Combine(templateDir, templateName+suffix);
+
+                // 濡傛灉鐩綍涓嶅瓨鍦�
+                if (!Directory.Exists(templateDir))
+                {
+                    Directory.CreateDirectory(templateDir);
+                }
+
+                // 濡傛灉鏂囦欢涓嶅瓨鍦�
+                if (!File.Exists(templateFile))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.Message = $"妯℃澘鏂囦欢涓嶅瓨鍦細{templateFile}";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                // 璇诲彇妯℃澘锛圲TF8 鏀寔涓枃锛�
+                string templateContent = File.ReadAllText(templateFile, Encoding.UTF8);
+
+                // 閫愯璇诲彇妯℃澘鏂囦欢
+                var lines = templateContent.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
+                var sb = new StringBuilder();
+
+                foreach(JToken JOneKVP in msg)
+                {
+                    if(JOneKVP is JObject item)
+                    {
+                        foreach (var line in lines)
+                        {
+                            string currentLine = line;
+
+                            // 璺宠繃娉ㄩ噴琛� //
+                            if (currentLine.TrimStart().StartsWith("//"))
+                            {
+                                continue;
+                            }
+
+                            // 姝e垯琛ㄨ揪寮忓尮閰� {{ 瀛楁鍚� }} 鎵�鍦ㄨ鐨勫瓧娈碉紝濡傛灉鏈夛紝鍒欒繘琛屾浛鎹紝娌℃湁锛屽垯榛樿涓虹┖瀛楃涓�
+                            currentLine = regex.Replace(currentLine, match =>
+                            {
+                                string fieldName = match.Groups[1].Value.Trim();
+                                if (msg != null && item.ContainsKey(fieldName))
+                                {
+                                    return item[fieldName]?.ToString() ?? "";
+                                }
+                                return "";
+                            });
+                            // 灏嗘墍鏈� \n 鐨勬崲琛岀 鏇挎崲涓� \r\n
+
+                            sb.Append(currentLine);
+                            sb.Append("\r\n"); // 鏍囧噯鎹㈣
+                        }
+                    }
+                }
+
+                
+                string result = sb.ToString().TrimEnd();
+                // 杩斿洖娓叉煋鍚庣殑鎵撳嵃鎸囦护
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = $"妯℃澘娓叉煋鎴愬姛";
+                objJsonResult.data = result;
+                return objJsonResult;
+            }
+            catch (Exception ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = $"妯℃澘娓叉煋澶辫触锛歿ex.Message}";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+        [HttpGet]
+        [Route("Web/getSysParameter")]
+        public object getSysParameter(string HClientID)
+        {
+            var HValue = oSystemParameter.GetSingleSystemParameter("uni-app_savelogin", ref DBUtility.ClsPub.sExeReturnInfo);
+            if (HValue == "3" && HClientID != null)
+            {
+                DataSet ds = oCN.RunProcReturn("select * from Gy_UserClientIdRelation where HClientID= '" + HClientID + "'", "Gy_UserClientIdRelation");
+                if (ds != null && ds.Tables.Count > 0)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鏍规嵁璁惧鑷姩鐧诲綍";
+                    objJsonResult.data = HValue;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绯荤粺鍙傛暟涓嶅瓨鍦紝璇疯仈绯荤鐞�";
+                    objJsonResult.data = 0;
+                    return objJsonResult;
+                }
+
+            }
+            else if (HValue == "2" || HValue == "1")
+            {
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛";
+                objJsonResult.data = HValue;
+                return objJsonResult;
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "绯荤粺鍙傛暟涓嶅瓨鍦紝璇疯仈绯荤鐞�";
+                objJsonResult.data = 0;
+                return objJsonResult;
+            }
+        }
     }
 }
+#endregion
\ No newline at end of file

--
Gitblit v1.9.1