From 6768e9f5d677e53e6d788d49e1ca5b9755236ca4 Mon Sep 17 00:00:00 2001 From: wtt <1985833171@qq.com> Date: 星期二, 22 十月 2024 13:56:24 +0800 Subject: [PATCH] 工艺路线关闭其它功能,分页异常bug修复 --- WebAPI/Controllers/BaseSet/Gy_SupplierController.cs | 243 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 243 insertions(+), 0 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs index 8f11c57..af67770 100644 --- a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs +++ b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs @@ -8,6 +8,8 @@ using System.Data.SqlClient; using System.Web.Http; using WebAPI.Models; +using System.Text.RegularExpressions; +using SyntacticSugar.constant; namespace WebAPI.Controllers { public class Gy_SupplierController : ApiController @@ -78,7 +80,61 @@ } } + #region 渚涘簲鍟嗗垎椤靛垪琛� + [Route("Gy_Supplier/page")] + [HttpGet] + public json Gy_SupplierPage(string sWhere, string user, int page, int size, string Organization) + { + DataSet ds; + json res = new json(); + try + { + List<object> columnNameList = new List<object>(); + //鍒ゆ柇鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + sWhere += ("and 缁勭粐鍚嶇О = '" + Organization + "'"); + sWhere = sWhere.Replace("'", "''"); + if (sWhere == null || sWhere.Equals("")) + { + ds = oCN.RunProcReturn("exec h_p_Gy_SupplierList " + page + "," + size + ",''", "h_p_Gy_SupplierList"); + } + else + { + ds = oCN.RunProcReturn("exec h_p_Gy_SupplierList " + page + "," + size + ",'" + sWhere + "'", "h_p_Gy_SupplierList"); + } + //娣诲姞鍒楀悕 + 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));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + res.code = CodeConstant.SUCCEED; + res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + res.Message = "Sucess锛�"; + res.list = columnNameList; + res.data = ds.Tables[0]; + return res; + } + catch (Exception e) + { + res.code = CodeConstant.FAIL; + res.count = CountConstant.FAIL; + res.Message = "Exception锛�" + e.ToString(); + res.data = null; + return res; + } + } + #endregion /// <summary> @@ -109,6 +165,83 @@ return objJsonResult; } } + + #region 瀹㈡埛鏍规嵁鍒嗙被鑾峰彇鏈�澶у鎴风紪鐮� + [Route("Gy_Supplier/getMaxNum")] + [HttpGet] + public object getMaxNum(int HSupTypeID, string user, string Organization) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (HSupTypeID == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁閫夋嫨鍏蜂綋鍒嗙被锛�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + ds = oCN.RunProcReturn(@"select * from h_v_Gy_SupplierList where 缁勭粐鍚嶇О='" + Organization + "'" + "and HSupTypeID = '" + HSupTypeID + "'" + " order by 渚涘簲鍟嗕唬鐮� desc", "h_v_Gy_SupplierList"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "娌℃湁鎵惧埌璇ュ垎绫荤殑瀹㈡埛缂栫爜璇蜂娇鐢ㄦ櫘閫氭柊澧�"; + objJsonResult.data = null; + return objJsonResult; + } + string HNumber = ds.Tables[0].Rows[0]["渚涘簲鍟嗕唬鐮�"].ToString(); + // 浣跨敤姝e垯琛ㄨ揪寮忔壘鍒版暟瀛楅儴鍒� (?<=\D)鏄竴涓浂瀹芥柇瑷�锛岃〃绀哄墠闈㈢殑瀛楃涓嶆槸鏁板瓧 (\d+)$琛ㄧず鍚庨潰璺熺潃涓�杩炰覆瀛楃涓茬煡閬撴湯灏� + Match match = Regex.Match(HNumber, @"(?<=\D)(\d+)$"); + if (match.Success) + { + string prefix = HNumber.Substring(0, HNumber.Length - match.Length); // 鎻愬彇鍓嶇紑 + int number = int.Parse(match.Value); // 瑙f瀽鏁板瓧 + // 鏁板瓧+1 + number++; + // 鏍煎紡鍖栨暟瀛楋紝淇濇寔鍘熼暱搴� + string formattedNumber = number.ToString().PadLeft(match.Length, '0'); + // 閲嶆柊缁勫悎瀛楃涓� + string result = prefix + formattedNumber; + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "success"; + objJsonResult.data = result; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + 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 /// <summary> /// 渚涘簲鍟嗗垪琛ㄤ慨鏀规寜閽柟娉� @@ -336,6 +469,7 @@ ///鍙傛暟锛歴tring sql銆� ///杩斿洖鍊硷細object銆� /// </summary> + [Route("Gy_Supplier/AddBill1")] [HttpPost] public object AddBill1([FromBody] JObject oMain) @@ -932,5 +1066,114 @@ } #endregion + #region 鏍规嵁鐖秈d鍜岀瓑绾ц幏寰楁爲鐘跺浘閫掑綊 + + [Route("Gy_BadReason/Gy_SupTypeTreeListByLevel")] + [HttpGet] + public object Gy_MaterTypeTreeListByLevel() + { + try + { + string sql1 = string.Format("select hitemid,hnumber,hname,hparentid,hlevel from Gy_SupType order by hnumber"); + + ds = oCN.RunProcReturn(sql1, "Gy_SupType"); + + List<TreeModel> treeModels = new List<TreeModel>(); + TreeModel first = new TreeModel(); + first.id = "0"; + first.title = "渚涘簲鍟嗗垎绫昏缃�"; + treeModels.Add(first); + + foreach (DataRow row in ds.Tables[0].Rows) + { + var HLevel = (int)row["hlevel"]; + if (HLevel == 1) + { + TreeModel tree = new TreeModel(); + tree.id = row["hitemid"].ToString(); + tree.title = row["hname"].ToString(); + treeModels[0].children.Add(tree); + } + } + getTreeByLevel(ds.Tables[0], treeModels[0].children, 2); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels); + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + public void getTreeByLevel(DataTable dt, List<TreeModel> tree, int num) + { + for (int m = 0; m < tree.Count; m++) + { + tree[m].children = new List<TreeModel>(); + for (int i = 0; i < dt.Rows.Count; i++)//绗竴娆″惊鐜紝寰楀埌鎵�鏈夋牴鑺傜偣鐨勫瓙闆� + { + var HLevel = (int)dt.Rows[i]["hlevel"]; + var HParentID = dt.Rows[i]["hparentid"].ToString(); + if (HLevel == num && HParentID == tree[m].id) + { + TreeModel tbjson = new TreeModel(); + tbjson.id = dt.Rows[i]["hitemid"].ToString(); + tbjson.title = dt.Rows[i]["hname"].ToString(); + tree[m].children.Add(tbjson); + } + } + for (int i = 0; i < tree[m].children.Count; i++) + { + getTreeByLevel(dt, tree[m].children, num + 1);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦 + } + } + + } + #endregion + + #region 鐗╂枡鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�) + public class TreeModel + { + public string id { get; set; } + public string title { get; set; } + public List<TreeModel> children = new List<TreeModel>(); + } + /// <summary> + /// 閫掑綊鍑芥暟 + /// </summary> + public void digui(DataTable dt, List<TreeModel> tree, int num) + { + for (int m = 0; m < tree.Count; m++) + { + tree[m].children = new List<TreeModel>(); + for (int i = 0; i < dt.Rows.Count; i++)//绗竴娆″惊鐜紝寰楀埌鎵�鏈夋牴鑺傜偣鐨勫瓙闆� + { + var strLen = dt.Rows[i]["hnumber"].ToString().Split('.'); + if (strLen.Length == num && dt.Rows[i]["hnumber"].ToString().Contains(tree[m].id + ".")) + { + TreeModel tbjson = new TreeModel(); + tbjson.id = dt.Rows[i]["hitemid"].ToString(); + tbjson.title = dt.Rows[i]["hname"].ToString(); + tree[m].children.Add(tbjson); + } + } + var strLens = tree[m].id.Split('.'); + for (int i = 0; i < tree[m].children.Count; i++) + { + digui(dt, tree[m].children, strLens.Length + 2);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦 + } + } + + } + + #endregion } } \ No newline at end of file -- Gitblit v1.9.1