From 2ec1b01d8a5e076eba607d83b902846876957a3e Mon Sep 17 00:00:00 2001 From: pzy <2829717936@qq.com> Date: 星期四, 03 十月 2024 23:00:03 +0800 Subject: [PATCH] 111 --- WebAPI/Controllers/BaseSet/Gy_CustomerController.cs | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 102 insertions(+), 14 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs index cd5c648..03f153d 100644 --- a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs +++ b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs @@ -9,6 +9,12 @@ using System.Web.Http; using WebAPI.Models; using System.Text.RegularExpressions; +using SyntacticSugar.constant; +using System.Web; +using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; +using WebAPI.WebBLL.JCJM.GYZL; +using WebAPI.WebBLL.JCJM.IMPL; +using System.IO; namespace WebAPI.Controllers { public class Gy_CustomerController : ApiController @@ -19,9 +25,10 @@ private json objJsonResult = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + private Gy_CustomerService customerService = new Gy_CustomerImpl(); DataSet ds; - + #region 杩斿洖瀹㈡埛鍒楄〃 /// <summary> /// 杩斿洖瀹㈡埛鍒楄〃 ///鍙傛暟锛歴tring sql銆� @@ -93,6 +100,7 @@ return objJsonResult; } } + #endregion #region 瀹㈡埛瀛愯〃[鍏宠仈鐢ㄦ埛] 鏌ヨ /// <summary> @@ -137,6 +145,7 @@ } #endregion + #region 瀹㈡埛鍒楄〃淇敼鎸夐挳鏂规硶 /// <summary> /// 瀹㈡埛鍒楄〃淇敼鎸夐挳鏂规硶 ///鍙傛暟锛歴tring sql銆� @@ -174,7 +183,7 @@ return objJsonResult; } } - + #endregion #region 鑾峰彇褰撳墠鏈�澶х殑瀹㈡埛浠g爜 [Route("Gy_Customer/getMaxCusNumber")] @@ -214,6 +223,7 @@ } #endregion + #region 鑾峰彇鏈�澶ц祫鏂橧D鍙傛暟 /// <summary> /// 鑾峰彇鏈�澶у熀纭�璧勬枡ID ///鍙傛暟锛歴tring sql銆� @@ -242,6 +252,7 @@ return objJsonResult; } } + #endregion #region 瀹㈡埛鏍规嵁鍒嗙被鑾峰彇鏈�澶у鎴风紪鐮� [Route("Gy_Customer/getMaxNum")] @@ -320,7 +331,7 @@ } #endregion - + #region 瀹㈡埛鍒楄〃鏍戝舰缁撴瀯 /// <summary> /// 瀹㈡埛鍒楄〃鏍戝舰缁撴瀯 ///鍙傛暟锛歴tring sql銆� @@ -350,7 +361,9 @@ return objJsonResult; } } + #endregion + #region 鏂板鍗曟嵁 /// <summary> /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳 ///鍙傛暟锛歴tring sql銆� @@ -506,9 +519,14 @@ return objJsonResult; } } + #endregion - - + #region 淇濆瓨瀹㈡埛鍒楄〃 + /// <summary> + /// 淇濆瓨瀹㈡埛鍒楄〃 + /// </summary> + /// <param name="oMain"></param> + /// <returns></returns> [Route("Gy_Customer/SaveGy_CustomerListApi")] [HttpPost] public object SaveGy_CustomerListApi([FromBody] JObject oMain) @@ -632,9 +650,9 @@ return objJsonResult; } } + #endregion - - + #region 淇敼鍗曟嵁-淇濆瓨鎸夐挳 /// <summary> /// 淇敼鍗曟嵁-淇濆瓨鎸夐挳 ///鍙傛暟锛歴tring sql銆� @@ -805,9 +823,9 @@ return objJsonResult; } } + #endregion - - + # region 瀹㈡埛鍒楄〃鍒犻櫎鎸夐挳 /// <summary> /// 瀹㈡埛鍒楄〃鍒犻櫎鎸夐挳 ///鍙傛暟锛歴tring sql銆� @@ -898,7 +916,7 @@ return objJsonResult; } } - + #endregion #region 瀹㈡埛瀹℃牳銆佸弽瀹℃牳 /// <summary> @@ -1090,7 +1108,6 @@ } #endregion - #region [鍚屾鍩虹璧勬枡] [Route("Gy_Customer/Gy_CustomerViewApi")] [HttpGet] @@ -1253,7 +1270,7 @@ } #endregion - #region 瀹㈡埛鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�) + #region 瀹㈡埛鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�) [Route("Gy_BadReason/Gy_CusrTypeTreeList")] [HttpGet] @@ -1309,7 +1326,7 @@ { try { - string sql1 = string.Format("select hitemid,hnumber,hname,hparentid,hlevel from Gy_CusType order by hnumber"); + string sql1 = string.Format("select hitemid,hnumber,hname,hparentid,hlevel from Gy_CusType order by hnumber "); ds = oCN.RunProcReturn(sql1, "Gy_CusType"); @@ -1349,7 +1366,77 @@ } #endregion + #region 瀹㈡埛鍒楄〃 鏂囦欢涓婁紶 + [Route("Gy_Customer/Gy_Process_Excel")] + [HttpPost] + public json Gy_Department_Excel() + { + json res = new json(); + try + { + //鑾峰彇鏂囦欢鍚嶇О + var file = HttpContext.Current.Request.Files[0]; + //鑾峰彇鏂囦欢鐗╃悊璺緞 + string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); + //淇濆瓨鏂囦欢 + file.SaveAs(ExcelPath); + NpoiHelper np = new NpoiHelper(); + DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); + //鍒犻櫎鏂囦欢 + File.Delete(ExcelPath); + DataTable provisional = customerService.UploadExcel(ExcelDs); + + res.code = CodeConstant.SUCCEED; + res.count = CountConstant.SUCCEED; + res.Message = "涓婁紶鎴愬姛"; + res.data = provisional; + return res; + } + catch (Exception e) + { + res.code = "0"; + res.count = 0; + res.Message = "Exception锛�" + e.ToString(); + res.data = null; + return res; + } + } + + /// <summary> + /// 鍒ゆ柇褰撳墠鑱屽憳鏄惁瀛樺湪 + /// </summary> + /// <param name="HEmpNumber"></param> + /// <param name="HEmpName"></param> + /// <returns></returns> + private bool JudgeEmp(string HEmpNumber, string HEmpName) + { + if (!String.IsNullOrEmpty(HEmpNumber) && !String.IsNullOrEmpty(HEmpName)) + { + DataSet emp = oCN.RunProcReturn("select * from Gy_Employee where HNumber = '" + HEmpNumber + "' and HName = '" + HEmpName + "'", "Gy_Employee"); + return emp.Tables[0].Rows.Count <= EmptyConstant.EMPTY ? true : false; + } + return false; + } + + /// <summary> + /// 鍒ゆ柇鍒� + /// </summary> + /// <param name="provisional"></param> + /// <returns></returns> + private static string JudgmentColumns(DataTable provisional) + { + var error = ""; + + //鏌ヨ娌℃湁鐨勫垪 + if (!provisional.Columns.Contains("閮ㄩ棬浠g爜")) + error += "娌℃湁鎵惧埌銆愰儴闂ㄤ唬鐮併�戠殑鏍囬,"; + + if (!provisional.Columns.Contains("閮ㄩ棬鍚嶇О")) + error += "娌℃湁鎵惧埌銆愰儴闂ㄥ悕绉般�戠殑鏍囬,"; + return error; + } + #endregion #region 鐗╂枡鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�) @@ -1375,7 +1462,6 @@ getTreeByLevel(dt, tree[m].children, num + 1);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦 } } - } public class TreeModel { @@ -1386,6 +1472,7 @@ #endregion + #region 閫掑綊鍑芥暟 /// <summary> /// 閫掑綊鍑芥暟 /// </summary> @@ -1415,4 +1502,5 @@ } } + #endregion } \ No newline at end of file -- Gitblit v1.9.1