From c3c3ba8325acc965729de86b896f4dbeea80b8a2 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期三, 22 四月 2026 13:26:46 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/WebAPIController.cs |  250 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 241 insertions(+), 9 deletions(-)

diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs
index b0fa4b8..bbc9e01 100644
--- a/WebAPI/Controllers/WebAPIController.cs
+++ b/WebAPI/Controllers/WebAPIController.cs
@@ -340,6 +340,7 @@
         /// <returns></returns>
         [Route("Web/GetUser")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetUser(string UserName, string PassWord, string HOrgName)
         {
             try
@@ -384,11 +385,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 +409,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 +2632,7 @@
         /// <returns></returns>
         [Route("Web/GetDataBases")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetDataBases()
         {
             try
@@ -18965,6 +18979,7 @@
         /// <returns></returns>
         [Route("Web/GetOrganizations")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetOrganizations()
         {
             try
@@ -18997,6 +19012,7 @@
         /// <returns></returns>
         [Route("Web/BaseInfo")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetBaseInfo()
         {
             try
@@ -20457,7 +20473,7 @@
             {
                 objjson.code = "0";
                 objjson.count = 0;
-                objjson.Message = "鑾峰彇澶辫触" + ex.ToString();
+                objjson.Message = "鑾峰彇澶辫触" + ex.Message.ToString();
                 objjson.data = null;
                 return objjson;
             }
@@ -21153,12 +21169,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 +22852,7 @@
         /// <returns></returns>
         [Route("Web/GetModuleName")]
         [HttpGet]
+        [AllowAnonymous]
         public object GetModuleName(string HModuleType)
         {
             try
@@ -23439,6 +23456,7 @@
         #region 鐢ㄤ簬杩炴帴鐨勫仴搴峰害妫�楠岋紝鍙鑳借闂�氳繖涓帴鍙o紝鍒欒〃鏄庤繛鎺ュ彲鐢�
         [Route("Health")]
         [HttpGet]
+        [AllowAnonymous]
         public IHttpActionResult CheckHealth()
         {
             // 杩斿洖 200 鐘舵�佺爜 纭鍋ュ悍鐘舵��
@@ -23837,5 +23855,219 @@
             }
         }
         #endregion
+
+        #region 鏍规嵁璁惧id鑾峰彇璁惧鏁伴噰鏁版嵁
+        private class EquipTechParam
+        {
+            public string TechParamName { get; set; }
+            public DateTime CreateTime { get; set; }
+            public string Result { get; set; }
+        }
+
+        [Route("Web/getSB_EquipTechParamBillListByEquipID")]
+        [HttpGet]
+        public object getSB_EquipTechParamBillListByEquipID(Int64 HEquipID)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                // 宸ヨ壓鍙傛暟鍒嗙被鍒楄〃
+                List<string> categoryNames = new List<string>();
+                ds = oCN.RunProcReturn($"exec h_p_SB_EquipTechParamBillListByEquipID {HEquipID}", "h_p_SB_EquipTechParamBillListByEquipID");
+                var ds1 = oCN.RunProcReturn($"select * from h_v_Gy_Technology", "h_v_Gy_Technology");
+
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "褰撳墠璁惧娌℃湁鏁伴噰淇℃伅";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                // 閬嶅巻鑾峰彇宸ヨ壓鍙傛暟鍒嗙被鍒楄〃
+                if (ds1.Tables[0].Rows.Count > 0)
+                {
+                    foreach (DataRow row in ds1.Tables[0].Rows)
+                    {
+                        string categoryName = row["宸ヨ壓鍙傛暟鍒嗙被鍚嶇О"].ToString().Trim();
+                        if (!string.IsNullOrEmpty(categoryName))
+                        {
+                            categoryNames.Add(categoryName);
+                        }
+                    }
+                }
+                // 鎻愬彇鍘熷鏁版嵁鍒版ā鍨嬪垪琛�
+                var rawParams = new List<EquipTechParam>();
+                foreach (DataRow row in ds.Tables[0].Rows)
+                {
+                    rawParams.Add(new EquipTechParam
+                    {
+                        TechParamName = row["HTechParamName"].ToString().Trim(),
+                        CreateTime = Convert.ToDateTime(row["HCreateTime"]),
+                        Result = row["HResult"].ToString()
+                    });
+                }
+
+                // 鎸夊伐鑹哄垎绫诲悕绉板垎缁�
+                Dictionary<string, List<EquipTechParam>> groupedParams = new Dictionary<string, List<EquipTechParam>>();
+                // 鍒濆鍖栨墍鏈夊伐鑹哄垎绫诲垎缁�
+                foreach (string category in categoryNames)
+                {
+                    groupedParams[category] = new List<EquipTechParam>();
+                }
+                // 鏂板鈥滃叾浠栧弬鏁扳�濆厹搴曞垎缁�
+                groupedParams["鍏朵粬鍙傛暟"] = new List<EquipTechParam>();
+
+                // 鍖归厤鍙傛暟鍒板搴斿垎缁勶紙鎸夊弬鏁板悕鍖呭惈鍒嗙被鍚嶇О瀛愪覆锛�
+                foreach (var param in rawParams)
+                {
+                    bool isMatched = false;
+                    // 閬嶅巻鎵�鏈夊伐鑹哄垎绫伙紝鍒ゆ柇鍙傛暟鍚嶆槸浠ヨ鍒嗙被鍚嶇О寮�澶�
+                    foreach (string category in categoryNames)
+                    {
+                        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; // 鍖归厤鍒扮涓�涓垎绫诲悗鍋滄锛堥伩鍏嶉噸澶嶅尮閰嶏級
+                        }
+                    }
+                    // 鏃犲尮閰嶅垎绫诲垯褰掍负鈥滃叾浠栧弬鏁扳��
+                    if (!isMatched)
+                    {
+                        groupedParams["鍏朵粬鍙傛暟"].Add(param);
+                    }
+                }
+
+                // 杞崲涓篔Array鏍煎紡锛堝墠绔彲鐩存帴瑙f瀽锛�
+                JArray resultJArray = new JArray();
+                foreach (var group in groupedParams)
+                {
+                    // 杩囨护绌哄垎缁勶紙鏃犳暟鎹殑鍒嗙被涓嶈繑鍥烇級
+                    if (group.Value.Count == 0) continue;
+
+                    JObject groupJObj = new JObject();
+                    groupJObj.Add("鍒嗙粍鍚嶇О", group.Key); // 宸ヨ壓鍙傛暟鍒嗙被鍚嶇О锛堝涓瓙銆佷繚鍘嬶級
+
+                    JArray paramsJArray = new JArray();
+                    foreach (var param in group.Value.OrderBy(p => p.TechParamName))
+                    {
+                        JObject paramJObj = new JObject();
+                        paramJObj.Add("HTechParamName", param.TechParamName);
+                        paramJObj.Add("HCreateTime", param.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
+                        paramJObj.Add("HResult", param.Result);
+                        paramsJArray.Add(paramJObj);
+                    }
+                    groupJObj.Add("鍙傛暟鍒楄〃", paramsJArray);
+                    resultJArray.Add(groupJObj);
+                }
+
+                // 淇濈暀鍘熸湁鍒楀悕閫昏緫锛堝吋瀹瑰墠绔級
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));
+                }
+
+                // 缁勮杩斿洖缁撴灉
+                objJsonResult.code = "1";
+                objJsonResult.count = resultJArray.Count; // 鏈夋晥鍒嗙粍鏁伴噺
+                objJsonResult.Message = "Success锛�";
+                objJsonResult.data = resultJArray;
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        /// <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;
+            }
+        }
     }
 }

--
Gitblit v1.9.1