From f331a2915eebc492e872206d9aa7e13fc7f0861f Mon Sep 17 00:00:00 2001 From: duhe <226547893@qq.com> Date: 星期一, 12 八月 2024 09:04:51 +0800 Subject: [PATCH] 1 --- WebAPI/Controllers/BaseSet/Gy_CustomerController.cs | 561 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 539 insertions(+), 22 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs index 90fb06d..f507d8a 100644 --- a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs +++ b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs @@ -42,7 +42,22 @@ objJsonResult.data = null; return objJsonResult; } - string sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 缁勭粐鍚嶇О='" + Organization + "'"); + string sql1 = ""; + //瀹㈡埛鍒跺畾 + string sErr = ""; + if (oSystemParameter.ShowBill(ref sErr)) + { + if (oSystemParameter.omodel.WMS_CampanyName == "涔斾竴") + { + sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 1=1"); + } + else + { + sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 缁勭粐鍚嶇О='" + Organization + "'"); + } + } + + if (sWhere == null || sWhere.Equals("")) { ds = oCN.RunProcReturn(sql1 + sWhere + " order by 瀹㈡埛浠g爜 ", "h_v_Gy_CustomerList"); @@ -78,6 +93,49 @@ } } + #region 瀹㈡埛瀛愯〃[鍏宠仈鐢ㄦ埛] 鏌ヨ + /// <summary> + /// 杩斿洖瀹㈡埛瀛愯〃[鍏宠仈鐢ㄦ埛]鍒楄〃 + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Gy_Customer/RelationUserlist")] + [HttpGet] + public object RelationUserlist(Int64 HCusID) + { + try + { + List<object> columnNameList = new List<object>(); + + string sql = "select * from h_v_Gy_Customer_RelationUsers_Query where HCusID = " + HCusID + " order by 鐢ㄦ埛缂栫爜 asc"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_Customer_RelationUsers_Query"); + + //娣诲姞鍒楀悕 + 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鍒楀璞$殑鍒楀悕 + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + /// <summary> /// 瀹㈡埛鍒楄〃淇敼鎸夐挳鏂规硶 ///鍙傛暟锛歴tring sql銆� @@ -90,7 +148,7 @@ try { string sql = string.Format(@"select c.HItemID,c.HNumber 瀹㈡埛浠g爜,c.HName 瀹㈡埛鍚嶇О,c.HHelpCode 鍔╄鐮�,c.HShortName 绠�绉�,c.HAddress 鍦板潃,c.HLinkMan 鑱旂郴浜�,c.HLinkPhone 鑱旂郴鐢佃瘽 - ,c.HMobilePhone 鎵嬫満,c.HFax 浼犵湡,c.HPostalCode 閭紪,c.HEmail 鐢靛瓙閭欢,c.HCorMan 娉曚汉浠h〃,c.HBank 寮�鎴烽摱琛�,c.HBankAccount 閾惰璐﹀彿, + ,c.HMobilePhone 鎵嬫満,c.HFax 浼犵湡,c.HPostalCode 閭紪,c.HEmail 鐢靛瓙閭欢,c.HCorMan 娉曚汉浠h〃,c.HBank 寮�鎴烽摱琛�,c.HBankAccount 閾惰璐﹀彿,c.HMateOutEmp 棰嗙敤浜�, c.HTaxNum 绋庡姟鐧昏鍙�,c.HTaxRate 澧炲�肩◣鐜�,c.HEnglishName 鑻辨枃鍚嶇О,c.HEngLishAddress 鑻辨枃鍦板潃,c.HCountry 鍥藉,c.HCusStatus 瀹㈡埛鐘舵�� ,c.HStopflag 绂佺敤鏍囧織,c.HRemark 澶囨敞,c.HAreaID 鍦板尯ID,a.HName 鍦板尯鍚嶇О,c.HCurID 榛樿璐у竵ID,r.HName 榛樿璐у竵, c.HSSID 缁撶畻鏂瑰紡ID,s.HName 缁撶畻鏂瑰紡,c.HCusTypeID 瀹㈡埛鍒嗙被ID,t.HName 瀹㈡埛鍒嗙被 from Gy_Customer c @@ -115,6 +173,45 @@ return objJsonResult; } } + + + #region 鑾峰彇褰撳墠鏈�澶х殑瀹㈡埛浠g爜 + [Route("Gy_Customer/getMaxCusNumber")] + [HttpGet] + public object getMaxCusNumber() + { + try + { + string sql = "select top(1) * from Gy_Customer order by HNumber desc"; + ds = oCN.RunProcReturn(sql, "Gy_Customer"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "灏氭湭瀛樺湪瀹㈡埛锛岃鑷富缁存姢瀹㈡埛浠g爜!"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = ""; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion /// <summary> /// 鑾峰彇鏈�澶у熀纭�璧勬枡ID @@ -257,7 +354,7 @@ DateTime HMakeTime = list[0].HMakeTime; long HCreateOrgID = list[0].HCREATEORGID; long HUseOrgID = list[0].HUSEORGID; - + string HMateOutEmp = list[0].HMateOutEmp; //DateTime HDeleteDate = list[0].HDeleteDate; @@ -285,9 +382,9 @@ ",HEmpID,HCreditDate,HCreditRatingDate,HMaxCreditRatingDate" + ",HMonthUseQty,HForecastCreditRating,HCreditLevelID,HCountAccrualRating" + ",HSubsidyAccrualRating,HCreditRating,HMaxCreditRating" + - ",HCusTypeID) " + + ",HCusTypeID,HCREATEORGID,HUSEORGID,HMateOutEmp) " + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID + - ", " + HLevel + ",0,'" + HStopflag + "','" + HRemark + "'" + + ", " + HLevel + ",1,'" + HStopflag + "','" + HRemark + "'" + ",'" + HShortName + "','" + HAddress + "','" + HLinkMan + "','" + HLinkPhone + "','" + HMobilePhone + "'" + ",'" + HFax + "','" + HPostalCode + "','" + HEmail + "','" + HBank + "','" + HBankAccount + "'" + ",'" + HTaxNum + "'," + HTaxRate + ",'" + HCountry + "','" + HCorMan + "','" + HEnglishName + "'" + @@ -295,9 +392,25 @@ "," + HEmpID + "," + HCreditDate + "," + HCreditRatingDate + "," + HMaxCredRatingDate + "," + HMonthUseQty + "," + HForecastCreditRating + "," + HCreditLevelID + "," + HCountAccrualRating + "," + HSubsidyAccrualRating + "," + HCreditRating + "," + HMaxCreditRating + - ", " + HCusTypeID + ")"); + ", " + HCusTypeID + ","+ HCreateOrgID + ","+ HUseOrgID + ",'"+ HMateOutEmp + "')"); //淇敼涓婄骇涓洪潪鏈骇浠g爜 oCN.RunProc("Update Gy_Customer set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); + + //淇濆瓨鍚庢帶鍒� + string sql = "select * from Gy_Customer where HNumber = '" + HNumber + "' and HName = '" + HName + "' and HUSEORGID = " + HUseOrgID; + ds = oCN.RunProcReturn(sql, "Gy_Customer"); + HItemID = Int64.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString()); + ds = oCN.RunProcReturn("exec h_p_Gy_Customer_AfterSaveCtrl " + HItemID, "h_p_Gy_Customer_AfterSaveCtrl"); + if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); + objJsonResult.data = null; + return objJsonResult; + } + oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; @@ -325,6 +438,7 @@ try { var model = oMain["model"].ToString(); + LogService.Write("瀹㈡埛:" + model); var custLocationModel = oMain["model"]["HCustLocationEntry"].ToString(); var custContactModel = oMain["model"]["HCustContactEntry"].ToString(); //鍙嶅簭鍒楀寲 @@ -338,8 +452,8 @@ oCN.RunProc(sql); sql = "set identity_insert gy_Customer on"; oCN.RunProc(sql); - //涓昏〃_瀹㈡埛 - oCN.RunProc("Insert into Gy_Customer " + + + LogService.Write("瀹㈡埛:" + "Insert into Gy_Customer " + " (HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID" + ",HLevel,HEndFlag,HStopflag,HRemark" + ",HShortName,HAddress,HLinkMan,HLinkPhone,HMobilePhone" + @@ -360,6 +474,28 @@ "," + lsmain[0].HMonthUseQty + "," + lsmain[0].HForecastCreditRating + "," + lsmain[0].HCreditLevelID + "," + lsmain[0].HCountAccrualRating + "," + lsmain[0].HSubsidyAccrualRating + "," + lsmain[0].HCreditRating + "," + lsmain[0].HMaxCreditRating + ", " + lsmain[0].HCusTypeID + ")"); + //涓昏〃_瀹㈡埛 + oCN.RunProc("Insert into Gy_Customer " + + " (HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark" + + ",HShortName,HAddress,HLinkMan,HLinkPhone,HMobilePhone" + + ",HFax,HPostalCode,HEmail,HBank,HBankAccount" + + ",HTaxNum,HTaxRate,HCountry,HCorMan,HEnglishName" + + ",HEnglishAddress,HCurID,HSSID,HAreaID,HCusStatus" + + ",HEmpID,HCreditDate,HCreditRatingDate,HMaxCreditRatingDate" + + ",HMonthUseQty,HForecastCreditRating,HCreditLevelID,HCountAccrualRating" + + ",HSubsidyAccrualRating,HCreditRating,HMaxCreditRating" + + ",HCusTypeID,HERPItemID) " + + " Values('" + lsmain[0].HItemID + "','" + lsmain[0].HNumber + "','" + lsmain[0].HName + "','" + lsmain[0].HHelpCode + "','" + lsmain[0].HShortNumber + "'," + lsmain[0].HParentID + + ", " + lsmain[0].HLevel + ",0,'" + lsmain[0].HStopFlag + "','" + lsmain[0].HRemark + "'" + + ",'" + lsmain[0].HShortName + "','" + lsmain[0].HAddress + "','" + lsmain[0].HLinkMan + "','" + lsmain[0].HLinkPhone + "','" + lsmain[0].HMobilePhone + "'" + + ",'" + lsmain[0].HFax + "','" + lsmain[0].HPostalCode + "','" + lsmain[0].HEmail + "','" + lsmain[0].HBank + "','" + lsmain[0].HBankAccount + "'" + + ",'" + lsmain[0].HTaxNum + "'," + lsmain[0].HTaxRate + ",'" + lsmain[0].HCountry + "','" + lsmain[0].HCorMan + "','" + lsmain[0].HEnglishName + "'" + + ",'" + lsmain[0].HEnglishAddress + "'," + lsmain[0].HCurID + "," + lsmain[0].HSSID + "," + lsmain[0].HAreaID + ",'" + lsmain[0].HCusStatus + "'" + + "," + lsmain[0].HEmpID + "," + lsmain[0].HCreditDate + "," + lsmain[0].HCreditRatingDate + "," + lsmain[0].HMaxCreditRatingDate + + "," + lsmain[0].HMonthUseQty + "," + lsmain[0].HForecastCreditRating + "," + lsmain[0].HCreditLevelID + "," + lsmain[0].HCountAccrualRating + + "," + lsmain[0].HSubsidyAccrualRating + "," + lsmain[0].HCreditRating + "," + lsmain[0].HMaxCreditRating + + ", " + lsmain[0].HCusTypeID + "," + lsmain[0].HItemID + ")"); sql = "set identity_insert gy_Customer off"; oCN.RunProc(sql); //瀹㈡埛_浜よ揣鍦扮偣 @@ -495,7 +631,7 @@ DateTime HMakeTime = list[0].HMakeTime; long HCreateOrgID = list[0].HCREATEORGID; long HUseOrgID = list[0].HUSEORGID; - + string HMateOutEmp = list[0].HMateOutEmp; //鍒ゆ柇鏉冮檺 if (!ClsPub.Security_Log(msg5, 1, false, msg4)) @@ -552,12 +688,28 @@ ",HAreaID ='" + HAreaID + "'" + ",HCusStatus ='" + HCusStatus + "'" + ",HCusTypeID ='" + HCusTypeID + "'" + - ",HRemark= '" + HRemark + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo); + ",HMateOutEmp='"+ HMateOutEmp+ + "',HRemark= '" + HRemark + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo); //淇敼瀛愰」鐩唬鐮� //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_Department,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo); //灏嗕笂绾� 涓洪潪鏈骇 oCN.RunProc("Update Gy_Customer set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); // + + //淇濆瓨鍚庢帶鍒� + ds = oCN.RunProcReturn("exec h_p_Gy_Customer_AfterSaveCtrl " + HItemID, "h_p_Gy_Customer_AfterSaveCtrl"); + if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); + objJsonResult.data = null; + return objJsonResult; + } + + + oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; @@ -619,25 +771,37 @@ return objJsonResult; } // - if (oDept.DeleteByID(HItemID)) + try { - //鍐欏叆鏃ュ織 - ClsPub.Add_Log("", "鍒犻櫎椤圭洰锛屼唬鐮侊細" + oDeptHlp.omodel.HNumber + ",鍚嶇О锛�" + oDeptHlp.omodel.HName, ClsPub.CurUserName); - //鏇存柊涓婄骇涓� 鏈骇 - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = "鍒犻櫎鎴愬姛"; - objJsonResult.data = null; - return objJsonResult; + if (oDept.DeleteByID(HItemID)) + { + //鍐欏叆鏃ュ織 + ClsPub.Add_Log("", "鍒犻櫎椤圭洰锛屼唬鐮侊細" + oDeptHlp.omodel.HNumber + ",鍚嶇О锛�" + oDeptHlp.omodel.HName, ClsPub.CurUserName); + //鏇存柊涓婄骇涓� 鏈骇 + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触"; + objJsonResult.data = null; + return objJsonResult; + } } - else + catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍒犻櫎澶辫触"; + objJsonResult.Message = "鍒犻櫎澶辫触锛岃瀹㈡埛瀛樺湪鍏宠仈鐨勯攢鍞鍗曘�侀攢鍞嚭搴撳崟銆佺敓浜ц鍗曪紝鎴栫▼搴忛敊璇��"; objJsonResult.data = null; return objJsonResult; } + } //ds = oCN.RunProcReturn("delete from Gy_Department where HItemID = " + HItemID, "Gy_Department"); @@ -656,6 +820,198 @@ return objJsonResult; } } + + + #region 瀹㈡埛瀹℃牳銆佸弽瀹℃牳 + /// <summary> + /// + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Gy_Customer/AuditGy_Customer")] + [HttpGet] + public object AuditGy_Customer(int HInterID, int IsAudit, string CurUserName) + { + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Customer_Check", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + var ds = oCN.RunProcReturn("select * from Gy_Customer where HItemID=" + HInterID, "Gy_Customer"); + if (ds.Tables[0].Rows.Count > 0) + { + if (IsAudit == 0) //瀹℃牳鍒ゆ柇 + { + if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍稿垽鏂� + { + if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!"; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.BeginTran(); + + if (IsAudit == 0) //瀹℃牳鍒ゆ柇 + { + oCN.RunProc("update Gy_Customer set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳鎴愬姛"; + objJsonResult.data = null; + } + if (IsAudit == 1) //鍙嶅鏍稿垽鏂� + { + oCN.RunProc("update Gy_Customer set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅鏍告垚鍔�"; + objJsonResult.data = null; + } + oCN.Commit(); + + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 瀹㈡埛绂佺敤銆佸弽绂佺敤 + /// <summary> + /// + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsStop">绂佺敤(0),鍙嶇鐢�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Gy_Customer/StopGy_Customer")] + [HttpGet] + public object StopGy_Customer(int HInterID, int IsStop, string CurUserName) + { + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Customer_Stop", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + var ds = oCN.RunProcReturn("select * from Gy_Customer where HItemID=" + HInterID, "Gy_Material"); + if (ds.Tables[0].Rows.Count > 0) + { + if (IsStop == 0) //绂佺敤鍒ゆ柇 + { + if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸茬鐢�!涓嶈兘鍐嶆绂佺敤锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂� + { + if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鐢�!涓嶉渶瑕佸弽绂佺敤!"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!"; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.BeginTran(); + + if (IsStop == 0) //绂佺敤鍒ゆ柇 + { + oCN.RunProc("update Gy_Customer set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "绂佺敤鎴愬姛"; + objJsonResult.data = null; + } + if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂� + { + oCN.RunProc("update Gy_Customer set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶇鐢ㄦ垚鍔�"; + objJsonResult.data = null; + } + oCN.Commit(); + + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绂佺敤澶辫触鎴栬�呭弽绂佺敤澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region [鍚屾鍩虹璧勬枡] [Route("Gy_Customer/Gy_CustomerViewApi")] @@ -791,7 +1147,7 @@ ,HLevel,HEndFlag,HStopflag,HRemark,HUseFlag,HMakeTime,HCREATEORGID,HUSEORGID ) values - ({jsonData.HItemID},{jsonData.HERPItemID},'{jsonData.HNumber}','{jsonData.HName}', + ({jsonData.HItemID},{jsonData.HItemID},'{jsonData.HNumber}','{jsonData.HName}', '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}','{jsonData.HUseFlag}','{jsonData.HMakeTime}',{jsonData.HCREATEORGID},{jsonData.HUSEORGID})"; oCN.RunProc(sql); @@ -819,5 +1175,166 @@ } #endregion + #region 瀹㈡埛鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�) + + [Route("Gy_BadReason/Gy_CusrTypeTreeList")] + [HttpGet] + public object Gy_CusrTypeTreeList() + { + try + { + string sql1 = string.Format("select hitemid,hnumber,hname from Gy_MaterType order by hnumber"); + + ds = oCN.RunProcReturn(sql1, "Gy_MaterType"); + + 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 strLen = row["hnumber"].ToString().Split('.'); + if (strLen.Length == 1) + { + TreeModel tree = new TreeModel(); + tree.id = row["hitemid"].ToString(); + tree.title = row["hname"].ToString(); + treeModels[0].children.Add(tree); + } + } + digui(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; + } + } + #endregion + + #region 鏍规嵁鐖秈d鍜岀瓑绾ц幏寰楁爲鐘跺浘閫掑綊 + + [Route("Gy_BadReason/Gy_CusTypeTreeListByLevel")] + [HttpGet] + public object Gy_CusTypeTreeListByLevel() + { + try + { + string sql1 = string.Format("select hitemid,hnumber,hname,hparentid,hlevel from Gy_CusType order by hnumber"); + + ds = oCN.RunProcReturn(sql1, "Gy_CusType"); + + 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; + } + } + #endregion + + + + #region 鐗╂枡鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�) + + 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);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦 + } + } + + } + public class TreeModel + { + public string id { get; set; } + public string title { get; set; } + public List<TreeModel> children = new List<TreeModel>(); + } + + #endregion + + /// <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);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦 + } + } + + } + } } \ No newline at end of file -- Gitblit v1.9.1